> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate Evaluation Metrics

# Calculate Model Metrics

After creating a model and uploading its predictions, you'll need to call this endpoint to update matches against ground truth annotations and calculate various metrics such as IOU. This will enable sorting by metrics, filtering down to false positives or false negatives, and a number of evaluation plots and metrics present in the Insights page.

You can continue to add model predictions to a dataset even after running the calculation of the metrics. However, the calculation of metrics will have to be retriggered for the new predictions to be matched with ground truth and update sorts, false positive/negative filters, and metrics used in the Insights page.

> [!NOTE]
>
> **How Nucleus matches predictions to ground truth**
>
> During IOU calculation for geometric predictions, predictions are greedily matched to ground truth by taking highest IOU pairs first. For segmentation predictions, a prediction and ground truth pair is matched if it has a IOU of more than 1% or if its a true positive. By default the matching algorithm is class-agnostic (`class_agnostic` defaults to `True`): it will greedily create matches regardless of the class labels.
>
> If you'd like to compute IOU by allowing associations between certain labels and predictions that don't have the same name, you can specify them using a list of `allowed_label_matches` (shown in the example below). When supplying `allowed_label_matches`, you must also set `class_agnostic` to `False`.

Note that this step will be completed automatically if you are working with [`CategoryPredictions`](https://api-reference.scale.com/docs/nucleus/category-predictions) (because matching predictions to ground truth is trivial).

```python theme={null}
from nucleus import NucleusClient

client = NucleusClient("YOUR_SCALE_API_KEY")
dataset = client.get_dataset(dataset_id="YOUR_DATASET_ID")

model = client.get_model(model_id="YOUR_MODEL_ID")

"""
associate car and bus bounding boxes for IOU computation,
but otherwise force associations to have the same class
"""
dataset.calculate_evaluation_metrics(model, options={
    "class_agnostic": False,
    "allowed_label_matches": [
        {
            "ground_truth_label": "car",
            "model_prediction_label": "bus"
        },
        {
            "ground_truth_label": "bus",
            "model_prediction_label": "car"
        }
    ]
})
```

Once your predictions' metrics have finished processing, you can check out the Objects tab or Insights page to explore, visualize, and debug your models and data!
