> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ovalbee.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ovalbee.com/_mcp/server.

# Get best model

> Finds the best model on a validation dataset version, carrying the previous round's winner over until it is measured there.

## Overview

Finds the best model measured on one version of a validation dataset and hands it to the next node.

It is made for an active learning round. Place it right after the node that saves the new validation version, next to the training nodes. It runs while the new models are still training, so it returns the best model of the previous round. Predict and evaluate that model on the new version, then compare each new model with it.

```mermaid
flowchart LR
  n1["Create version"] --> n2["Get best model"] --> n3["Apply model"] --> n4["Evaluate object detection"] --> n6["Compare object detectors"]
  n1 --> n5["Train"] --> n7["Predict"] --> n8["Evaluate object detection"] --> n6
```

## How it works

Ranks the models evaluated on the **Validation dataset** version by **Metric**. Each **Task type** has its own metrics to pick from.

When the best model of the previous version has no evaluation on this one yet, returns that model instead, and the log says it still has to be evaluated here.

When no model has been evaluated on any version of the dataset yet, stops this branch, so the nodes after it do not run.

Returns the model, its framework and the dataset version it ranked on, and shows the model name and version on the badge.

## FAQ

#### Why does it not return the model that just finished training?

It only ranks models evaluated on this dataset version. When it runs at the start of a round, the new models have no evaluations yet, so they cannot be picked. This is what makes it return the previous best model.

#### Why are evaluations from older dataset versions not compared?

Each version of a validation dataset holds different images, so scores from two versions do not compare. The previous best model is evaluated again on the new version instead.

#### How do I predict with the best model when it can be YOLO or DEIM?

Wire **Best model framework** into a [Router](/node-library/nodes/flow-control-router) and add one rule per framework, such as `yolo` and `deim`. Each rule's edge leads to the Predict node of that framework.

#### What happens when two models have the same score?

The older model wins. The log names both models, the shared score and which one was kept.

#### Can I connect the newest version of the dataset?

Yes, but pin a saved version when you can. Labeling keeps changing the newest version, and an evaluation made before a change stops counting, so models would have to be evaluated again.

#### Which models can it pick?

The models of this workspace that have an evaluation on the dataset version and perform the selected **Task type**. A model uploaded by hand counts too, once it has been evaluated.

## Inputs

**`Validation dataset`** `dataset` — required

Validation dataset version the models are ranked on. Pin a saved version, such as the output of Create version. Key: `EVAL_DATASET`.

---

**`Task type`** `select` — required, default: object_detection

Task the ranked models perform. Key: `TASK_TYPE`.

Options:

* Object detection (`object_detection`)
* Instance segmentation (`instance_segmentation`)
* Semantic segmentation (`semantic_segmentation`)
* Classification (`classification`)
* Tracking (`tracking`)

---

**`Metric`** `select` — required, default: map50_95

Object detection metric that ranks the models. Visible when `TASK_TYPE` is `object_detection`. Key: `OBJECT_DETECTION_METRIC`.

Options:

* mAP 50-95 (`map50_95`)
* mAP 50 (`map50`)
* Precision (`precision`)
* Recall (`recall`)
* F1 (`f1`)

---

**`Metric`** `select` — required, default: mask_map50_95

Instance segmentation metric that ranks the models. Visible when `TASK_TYPE` is `instance_segmentation`. Key: `INSTANCE_SEGMENTATION_METRIC`.

Options:

* Mask mAP 50-95 (`mask_map50_95`)
* Mask mAP 50 (`mask_map50`)
* Mask precision (`mask_precision`)
* Mask recall (`mask_recall`)
* Mask F1 (`mask_f1`)

---

**`Metric`** `select` — required, default: miou

Semantic segmentation metric that ranks the models. Visible when `TASK_TYPE` is `semantic_segmentation`. Key: `SEMANTIC_SEGMENTATION_METRIC`.

Options:

* mIoU (`miou`)
* Boundary mIoU (`mboundary_iou`)
* Mean F1 (`mf1`)
* Mean precision (`mprecision`)
* Mean recall (`mrecall`)
* Pixel accuracy (`pixel_acc`)

---

**`Metric`** `select` — required, default: accuracy_top1

Classification metric that ranks the models. Visible when `TASK_TYPE` is `classification`. Key: `CLASSIFICATION_METRIC`.

Options:

* Top-1 accuracy (`accuracy_top1`)
* Weighted F1 (`f1_weighted`)
* Macro F1 (`f1_macro`)

---

**`Metric`** `select` — required, default: hota

Tracking metric that ranks the models. Visible when `TASK_TYPE` is `tracking`. Key: `TRACKING_METRIC`.

Options:

* HOTA (`hota`)
* MOTA (`mota`)
* IDF1 (`idf1`)
* DetA (`deta`)
* AssA (`assa`)
* LocA (`loca`)

---

## Outputs

**`Best model`** `model`

Registry reference of the best model. Empty when no model has been evaluated on this dataset yet. Key: `BEST_MODEL_ID`.

---

**`Best model framework`** `string`

Framework of the best model, such as yolo, to branch on in a Router. Empty when no model has been evaluated on this dataset yet. Key: `BEST_MODEL_FRAMEWORK`.

---

**`Validation dataset`** `dataset`

The validation dataset version the ranking ran on, pinned, for the Predict and Evaluate nodes of the best model. Key: `EVAL_DATASET`.

---

**`Best`** `string`

Name and version of the best model. Shown on the node as a badge. Key: `BEST`.

---

## JSON config

Machine-readable node interface for automation and advanced usage.

#### Show JSON

```json
{
  "name": "Get best model",
  "description": "Finds the best model on a validation dataset version, carrying the previous round's winner over until it is measured there.",
  "category": "Models",
  "namespace": "ovalbee",
  "templateKey": "models/general/get_best_model",
  "version": "v1",
  "inputs": [
    {
      "key": "EVAL_DATASET",
      "label": "Validation dataset",
      "type": "dataset",
      "description": "Validation dataset version the models are ranked on. Pin a saved version, such as the output of Create version.",
      "required": true,
      "default": null,
      "visibleWhen": null,
      "options": {
        "creatable": false
      }
    },
    {
      "key": "TASK_TYPE",
      "label": "Task type",
      "type": "select",
      "description": "Task the ranked models perform.",
      "required": true,
      "default": "object_detection",
      "visibleWhen": null,
      "options": {
        "options": [
          {
            "label": "Object detection",
            "value": "object_detection"
          },
          {
            "label": "Instance segmentation",
            "value": "instance_segmentation"
          },
          {
            "label": "Semantic segmentation",
            "value": "semantic_segmentation"
          },
          {
            "label": "Classification",
            "value": "classification"
          },
          {
            "label": "Tracking",
            "value": "tracking"
          }
        ]
      }
    },
    {
      "key": "OBJECT_DETECTION_METRIC",
      "label": "Metric",
      "type": "select",
      "description": "Object detection metric that ranks the models.",
      "required": true,
      "default": "map50_95",
      "visibleWhen": {
        "key": "TASK_TYPE",
        "operator": "equals",
        "value": "object_detection"
      },
      "options": {
        "options": [
          {
            "label": "mAP 50-95",
            "value": "map50_95"
          },
          {
            "label": "mAP 50",
            "value": "map50"
          },
          {
            "label": "Precision",
            "value": "precision"
          },
          {
            "label": "Recall",
            "value": "recall"
          },
          {
            "label": "F1",
            "value": "f1"
          }
        ]
      }
    },
    {
      "key": "INSTANCE_SEGMENTATION_METRIC",
      "label": "Metric",
      "type": "select",
      "description": "Instance segmentation metric that ranks the models.",
      "required": true,
      "default": "mask_map50_95",
      "visibleWhen": {
        "key": "TASK_TYPE",
        "operator": "equals",
        "value": "instance_segmentation"
      },
      "options": {
        "options": [
          {
            "label": "Mask mAP 50-95",
            "value": "mask_map50_95"
          },
          {
            "label": "Mask mAP 50",
            "value": "mask_map50"
          },
          {
            "label": "Mask precision",
            "value": "mask_precision"
          },
          {
            "label": "Mask recall",
            "value": "mask_recall"
          },
          {
            "label": "Mask F1",
            "value": "mask_f1"
          }
        ]
      }
    },
    {
      "key": "SEMANTIC_SEGMENTATION_METRIC",
      "label": "Metric",
      "type": "select",
      "description": "Semantic segmentation metric that ranks the models.",
      "required": true,
      "default": "miou",
      "visibleWhen": {
        "key": "TASK_TYPE",
        "operator": "equals",
        "value": "semantic_segmentation"
      },
      "options": {
        "options": [
          {
            "label": "mIoU",
            "value": "miou"
          },
          {
            "label": "Boundary mIoU",
            "value": "mboundary_iou"
          },
          {
            "label": "Mean F1",
            "value": "mf1"
          },
          {
            "label": "Mean precision",
            "value": "mprecision"
          },
          {
            "label": "Mean recall",
            "value": "mrecall"
          },
          {
            "label": "Pixel accuracy",
            "value": "pixel_acc"
          }
        ]
      }
    },
    {
      "key": "CLASSIFICATION_METRIC",
      "label": "Metric",
      "type": "select",
      "description": "Classification metric that ranks the models.",
      "required": true,
      "default": "accuracy_top1",
      "visibleWhen": {
        "key": "TASK_TYPE",
        "operator": "equals",
        "value": "classification"
      },
      "options": {
        "options": [
          {
            "label": "Top-1 accuracy",
            "value": "accuracy_top1"
          },
          {
            "label": "Weighted F1",
            "value": "f1_weighted"
          },
          {
            "label": "Macro F1",
            "value": "f1_macro"
          }
        ]
      }
    },
    {
      "key": "TRACKING_METRIC",
      "label": "Metric",
      "type": "select",
      "description": "Tracking metric that ranks the models.",
      "required": true,
      "default": "hota",
      "visibleWhen": {
        "key": "TASK_TYPE",
        "operator": "equals",
        "value": "tracking"
      },
      "options": {
        "options": [
          {
            "label": "HOTA",
            "value": "hota"
          },
          {
            "label": "MOTA",
            "value": "mota"
          },
          {
            "label": "IDF1",
            "value": "idf1"
          },
          {
            "label": "DetA",
            "value": "deta"
          },
          {
            "label": "AssA",
            "value": "assa"
          },
          {
            "label": "LocA",
            "value": "loca"
          }
        ]
      }
    }
  ],
  "outputs": [
    {
      "key": "BEST_MODEL_ID",
      "label": "Best model",
      "type": "model",
      "description": "Registry reference of the best model. Empty when no model has been evaluated on this dataset yet.",
      "artifact": false,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "BEST_MODEL_FRAMEWORK",
      "label": "Best model framework",
      "type": "string",
      "description": "Framework of the best model, such as yolo, to branch on in a Router. Empty when no model has been evaluated on this dataset yet.",
      "artifact": false,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "EVAL_DATASET",
      "label": "Validation dataset",
      "type": "dataset",
      "description": "The validation dataset version the ranking ran on, pinned, for the Predict and Evaluate nodes of the best model.",
      "artifact": false,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "BEST",
      "label": "Best",
      "type": "string",
      "description": "Name and version of the best model.",
      "artifact": false,
      "badge": true,
      "badgeOpens": null,
      "hidden": false
    }
  ]
}
```