Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mwalmsley/zoobot/llms.txt
Use this file to discover all available pages before exploring further.
FinetuneableZoobotClassifier adapts a pretrained Zoobot encoder for classification tasks — finding rings, bars, mergers, or any discrete morphological category. It attaches a linear head to the encoder output and trains with cross-entropy loss. For binary classification (num_classes=2) it automatically uses binary accuracy metrics; for more than two classes it uses micro-averaged multi-class accuracy.
Quick Example
finetune_rings.py
Constructor Parameters
All parameters from FinetuneableZoobotAbstract are accepted. The following are specific to the classifier.Number of target classes. Use
2 for binary classification (e.g. ring/not-ring), or more for multi-class problems (e.g. 4 Hubble types).Name of the column in the batch dictionary containing integer class labels. This should match a key in your catalog and
label_cols list passed to CatalogDataModule.Smoothing factor for cross-entropy loss. Redistributes a fraction of probability mass from the target class to other classes. Can improve calibration on noisy labels.
Per-class weights for cross-entropy loss. Useful for highly imbalanced datasets. Example:
[1.0, 5.0] weights the positive class 5x more heavily for a 5:1 negative:positive imbalance.If
True, fits an sklearn.linear_model.LogisticRegression on frozen encoder features before finetuning begins. Logs linear evaluation accuracy to WandB/CSV. Useful to verify the pretrained features are informative for your task.Metrics Logged
| Metric | Description |
|---|---|
finetuning/train_loss | Cross-entropy loss on training set (per epoch) |
finetuning/val_loss | Cross-entropy loss on validation set (per epoch) |
finetuning/train_acc | Accuracy on training set |
finetuning/val_acc | Accuracy on validation set |
finetuning/test_acc | Accuracy on test set (when trainer.test() is called) |
Prediction
predict_step applies softmax to the head logits and returns class probabilities of shape (batch_size, num_classes).
['ring', 'id_str'] where ring contains the softmax probability for class index 0 (for binary problems, you likely want column index 1 for the positive class probability).
For multi-class problems, the output DataFrame will have one column per class, named after each entry in
label_cols.