Guides / Evaluate a model
Evaluate a model¶
This guide scores a trained model on its test stars, and shows how to read the metrics and plots that it writes.
What you need¶
A checkpoint directory written by
dorothy train(Train a model).The catalogue the model was trained on, at the
data.catalogue_pathof the checkpoint’sconfig.yaml.
Step 1: Run the evaluation¶
dorothy evaluate outputs/boss_apogee/boss_apogee_final
The command reloads the catalogue and takes the test stars of the training
run from data_split.pkl. These stars took no part in training or in the
choice of the best epoch. It predicts their labels with best_model.pth and
the calibrated uncertainties, and compares the predictions with the catalogue
labels.
Dorothy’s note
Run dorothy evaluate from the directory you trained in. The checkpoint
stores data.catalogue_path as you wrote it, so a relative path is read from
the current directory.
Step 2: Read the metrics¶
For each label source, the output usually has three blocks:
Block |
Contents |
|---|---|
|
metrics in normalized units, comparable across parameters |
|
metrics in K for Teff and dex for the others |
|
the calibration factor of each parameter, with |
With calibration factors (the default), the z-score metrics and s_p16 to
s_p84 use the calibrated uncertainty. So only the prediction metrics of the
normalized block equal the validation metrics of training. With
--no-calibration, all of them do.
Some runs print fewer blocks or tables:
Without calibration factors, there is no
CALIBRATIONblock. This happens with--no-calibration, with--model final_model.pth, and after training withcalibrate_uncertainties: falseorloss: mse.Without a label normalizer, one
METRICSblock replaces the two metrics blocks.With
loss: mse, the metrics blocks have no z-score table.
Each metrics block otherwise has three tables, with one row per parameter. Each metric answers one question:
Question |
Metrics |
|---|---|
How far are the predictions from the labels? |
|
Are the predictions offset? |
|
Are the uncertainties right? |
|
How large are the uncertainties? |
|
Rob.Scatter and Med.Offset come from percentiles, so a few outliers do
not change them; RMSE, Bias and SD include the outliers.
Evaluation defines each metric.
Step 3: Look at the plots¶
The command writes four plots per label source to the checkpoint’s
plots/evaluation/ directory:
File |
Shows |
|---|---|
|
prediction against catalogue label, coloured by the uncertainty |
|
the density of label minus prediction against the label, with running quartiles |
|
the distributions of the labels and the predictions |
|
the z-scores against a standard normal distribution |
Look for a trend in the residuals: predictions too low at one end of a parameter’s range and too high at the other. The z-score histograms should follow the normal curve; wider histograms mean that the uncertainties are too small.
Step 4: Save the results¶
dorothy evaluate outputs/boss_apogee/boss_apogee_final \
--format json --output results.json
The JSON file holds the metrics of every label source under label_sources,
and those of the first label source also at the top level. --format markdown writes the tables as Markdown. Commands
lists the other options, such as --model for another weights file.
Next¶
Read the predictions: when to trust a label.
Inspect a model: which pixels a prediction depends on.