Skip to navigation

Compare classifiers

Dockerfile
First run can take longer while the worker pulls the configured Docker image.

Overview

Puts two to five classifiers side by side on the same dataset and names the best one.

You pick the evaluations from one list, so comparing three or four models takes one node instead of a chain. The winner is chosen by the same model ranking that Get best model uses, so both nodes always agree on which model is best. The winning model, its evaluation and its report come out as outputs, so the flow can carry on with it.

Evaluate classifier Compare classifiers Export TIMM to ONNX

Prerequisites

RequirementWhat you need
EvaluationsTwo to five evaluations from the Evaluate classifier node, each with its report kept.
Shared datasetAll evaluations made on the same test or validation dataset, so the scores are comparable.

How it works

1

Ranks the selected evaluations by Metric and picks the winner.

2

Reads each evaluation report and keeps only the images that every model scored.

3

Recomputes accuracy, macro F1, weighted F1 and per-class scores for every model on those images.

4

Publishes the comparison report along with the winner’s model, evaluation and report.

FAQ

The one you pick in Metric: accuracy (the default), weighted F1 or macro F1. Set it to the same value as the classification Metric of Get best model, and both nodes pick the same model. Weighted F1 follows class sizes, while macro F1 gives every class the same weight, so it’s the better choice when rare classes matter to you.

The older model wins. The run log says which models tied, on what value, and which one was kept.

The winner comes from the scores each evaluation recorded. The report recomputes every score on the images all models share, so if one evaluation covered extra images, its report numbers can be a little different.

The evaluations don’t share a single image. Check that they were all made on the same dataset.

The node needs the per-image results from an Evaluate classifier report. An evaluation that has no report, or whose report came from another node, can’t be compared.

Inputs

Evaluation dataset
datasetRequired

Test or validation dataset the classifiers were evaluated on. Key: GT_DATASET.

Classifier evaluations
model_evaluationRequired

Two to five evaluations of this dataset to compare, in any order. Values come from GT_DATASET. Key: EVALUATIONS.

Metric
selectDefaults to accuracy_top1Required

Evaluation metric that picks the winner. Bind it to the classification Metric of Get best model so both pick by the same rule. Key: RANKING_METRIC.

Options:

  • Accuracy (accuracy_top1)
  • Weighted F1 (f1_weighted)
  • Macro F1 (f1_macro)

Outputs

Report Asset
report

Asset ID containing the comparison report. Shown as an artifact. Key: REPORT_ID.

Best Model ID
model

Registry reference of the winning model (highest on Metric). Shown as an artifact. Key: BEST_MODEL_ID.

Winner framework
string

Framework of the winning model, such as yolo, to branch on in a Router. Key: WINNER_FRAMEWORK.

Best Report ID
report

Evaluation report asset ID of the winning model (can be passed to another Compare node). Key: BEST_REPORT_ID.

Best Evaluation ID
model_evaluation

Evaluation of the winning model, ready to wire into another comparison. Key: BEST_EVALUATION_ID.

Winner
string

Name of the winning model and its score on Metric. Shown on the node as a badge. Key: WINNER.

Models and configuration

Metric is the only setting. The evaluation settings themselves come from the Evaluate classifier runs you select.

Report

The comparison report opens in the preview widget:

  • Overview: the winner and its score on Metric, then a table of accuracy, macro F1 and weighted F1 for every model.
  • Per-class comparison: F1, precision and recall for each class, all models on one scale.
  • Change against the first model: per-class F1 difference of every other model against the first one you picked.
  • Confusion matrices: one per model, on the same class order.
  • Per-image results: every image with each model’s prediction, confidence and how many models got it right.

Runtime

Runs on an ordinary worker. It reads a few reports and writes one, so it finishes quickly even on large datasets.

JSON config

Machine-readable node interface for automation and advanced usage.

{
"name": "Compare classifiers",
"description": "Compare two to five classifier evaluations on the same dataset. Produces a side-by-side report with overall and per-class metrics and names the winner.",
"category": "Evaluate",
"namespace": null,
"templateKey": "evaluate/compare_classifiers",
"version": "v2",
"inputs": [
{
"key": "GT_DATASET",
"label": "Evaluation dataset",
"type": "dataset",
"description": "Test or validation dataset the classifiers were evaluated on.",
"required": true,
"default": null,
"visibleWhen": null,
"options": {
"creatable": false
}
},
{
"key": "EVALUATIONS",
"label": "Classifier evaluations",
"type": "model_evaluation",
"description": "Two to five evaluations of this dataset to compare, in any order.",
"required": true,
"default": null,
"visibleWhen": null,
"options": {
"ref": "GT_DATASET",
"task_type": "classification",
"minItems": 2,
"maxItems": 5
}
},
{
"key": "RANKING_METRIC",
"label": "Metric",
"type": "select",
"description": "Evaluation metric that picks the winner. Bind it to the classification Metric of Get best model so both pick by the same rule.",
"required": true,
"default": "accuracy_top1",
"visibleWhen": null,
"options": {
"options": [
{
"label": "Accuracy",
"value": "accuracy_top1"
},
{
"label": "Weighted F1",
"value": "f1_weighted"
},
{
"label": "Macro F1",
"value": "f1_macro"
}
]
}
}
],
"outputs": [
{
"key": "REPORT_ID",
"label": "Report Asset",
"type": "report",
"description": "Asset ID containing the comparison report.",
"artifact": true,
"badge": false,
"badgeOpens": null,
"hidden": false
},
{
"key": "BEST_MODEL_ID",
"label": "Best Model ID",
"type": "model",
"description": "Registry reference of the winning model (highest on Metric).",
"artifact": true,
"badge": false,
"badgeOpens": null,
"hidden": false
},
{
"key": "WINNER_FRAMEWORK",
"label": "Winner framework",
"type": "string",
"description": "Framework of the winning model, such as yolo, to branch on in a Router.",
"artifact": false,
"badge": false,
"badgeOpens": null,
"hidden": false
},
{
"key": "BEST_REPORT_ID",
"label": "Best Report ID",
"type": "report",
"kind": "classification_evaluation_report_v1",
"description": "Evaluation report asset ID of the winning model (can be passed to another Compare node).",
"artifact": false,
"badge": false,
"badgeOpens": null,
"hidden": false
},
{
"key": "BEST_EVALUATION_ID",
"label": "Best Evaluation ID",
"type": "model_evaluation",
"description": "Evaluation of the winning model, ready to wire into another comparison.",
"artifact": false,
"badge": false,
"badgeOpens": null,
"hidden": false
},
{
"key": "WINNER",
"label": "Winner",
"type": "string",
"description": "Name of the winning model and its score on Metric.",
"artifact": false,
"badge": true,
"badgeOpens": null,
"hidden": false
}
],
"runtime": {
"type": "docker",
"devices": [
"cpu"
],
"dockerImage": "ovalbee/node-classifier-inference:0.0.27"
},
"automation": {
"requires_configuration": true
},
"widgets": {
"widget": {
"id": "report-preview",
"settings": {
"reportAsset": {
"type": "variable",
"value": "self.outputs.REPORT_ID"
},
"name": {
"type": "input",
"value": "Open comparison"
}
}
}
}
}

References