LION.evaluation.evaluation¶
Evaluating a reconstruction method on a test set.
Evaluation is the standard evaluation of one problem, like an
Experiment: the test data (an experiment’s split, or a dataset), the
operator, the metrics (PSNR, SSIM, HaarPSI) and how their range is set. Its
run(method) scores every test sample and gives a test record:
name,method(what was run, e.g. a model’s spec and weights hash);evaluation(this evaluation’s spec),data(the test data’s record,LION.data_loaders.data_record),metrics(their specs; and whetherhigher_is_better),data_range;scores: the sampleidsand, per metric, the score of each sample;summary: per metricmean,std,median,q25,q75,min,max;seconds_per_sample;environment.
Records are LIONParameter``s, saved as plain JSON in ``save_folder (by
default $LION_RESULTS_PATH/evaluations). Running the same method on the
same evaluation again reads the saved record instead of recomputing it.
The functions work on their own too: scores (one method on some data),
summary, table (records as markdown, LaTeX or CSV).
Classes
|
The standard evaluation of one problem (see the module docstring). |
Functions
PSNR, SSIM and HaarPSI. |
|
|
Whether |
|
A test record: a record, or the path of its |
|
The IDs of a dataset's samples (their indices if it has none). |
|
Every sample of |
|
The summary of a test record, |
|
Mean, std, median, quartiles, min and max (NaNs left out). |
|
Records as a table: one row per method (its |
- class LION.evaluation.evaluation.Evaluation(experiment=None, dataset=None, operator=None, split='test', metrics=None, normalisation='dataset', samples=None, batch_size=1, save_folder=None, device=None)[source]¶
Bases:
objectThe standard evaluation of one problem (see the module docstring).
experiment: itssplitis the test data, and its geometry gives the operator; ordataset(andoperator) for data set up without an experiment.metrics:{name: metric}, by default PSNR, SSIM and HaarPSI.normalisation: the range the metrics use:"dataset"(the test samples’ minimum and maximum, the same for every method; default),"sample"(each target’s own range),(min, max), or a LIONNormalisation.samples: all (None),n(evenly spaced over the test set) or a list of sample IDs.save_folder: where records are saved and reused (default$LION_RESULTS_PATH/evaluations; None without it).device: where methods run (default LION’s).- run(x, name=None, *, save=True, allow=(), verbose=1)[source]¶
Score
x(a model, a model’s file, a solver, a reconstructor or a functionf(y, operator); seeLION.evaluation.method) on every test sample. Returns its test record, saved insave_folder; a record saved before for the same method and evaluation is read instead.allow: modules outside LION a model file may name (e.g. your own solver).verbose: 1 (default) shows a progress bar over the test samples; 0 nothing.
- LION.evaluation.evaluation.is_test_record(value)[source]¶
Whether
value(a dict or aLIONParameter) is a test record (Evaluation’s): it has the record’s key.
- LION.evaluation.evaluation.read_test_record(source)[source]¶
A test record: a record, or the path of its
.json.
- LION.evaluation.evaluation.sample_ids(data)[source]¶
The IDs of a dataset’s samples (their indices if it has none).
- LION.evaluation.evaluation.scores(run, data, metrics, data_range=None, batch_size=1, device=None, verbose=0, desc=None)[source]¶
Every sample of
data(a dataset of(measurement, target)) throughrun, in order, scored by every metric.data_range:(min, max)(outputs and targets are shifted byminand the metrics getmax - min), or None for each target’s own range.Returns
(ids, {name: numpy array of per-sample scores}, seconds per sample).verbose >= 1: a progress bar over the samples (desc).
- LION.evaluation.evaluation.summary(record)[source]¶
The summary of a test record,
{metric: {mean, std, ...}}.
- LION.evaluation.evaluation.summary_of(values)[source]¶
Mean, std, median, quartiles, min and max (NaNs left out).
- LION.evaluation.evaluation.table(records, format='markdown', digits=None)[source]¶
Records as a table: one row per method (its
name), one column per metric,mean ± std, the best of each column in bold.format:"markdown","latex"(booktabs) or"csv"(mean and std columns).digits: decimals per metric (default: 2 for values of 10 or more, else 4).