> ## 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 Model Metrics

> [!NOTE]
>
> **[Click for Python SDK](https://docs.nucleus.scale.com/en/latest/api/nucleus/index.html#nucleus.Dataset.calculate_evaluation_metrics)**
>
> ```
> Dataset.calculate_evaluation_metrics(
>     model: Model,
>     options: Dict{
>         "class_agnostic": bool,
>         "allowed_label_matches": List[dict]
>     }
> ) -> AsyncJob
> ```

This endpoint updates matches and metrics for a Model on a given Dataset (and its ground truth Annotations). This is required in order to sort by IoU, view false positives/false negatives, and view model insights.

You can add predictions from a model to a Dataset after running the calculation of the metrics. However, the calculation of metrics will have to be re-triggered for the new predictions to be matched with ground truth and appear as false positives/negatives, or for the new predictions effect on metrics to be reflected in model run insights.

During IoU calculation, bounding box Predictions are compared to ground truth Annotations using a greedy matching algorithm that matches prediction and ground truth boxes that have the highest IoUs first. By default the matching algorithm is class-agnostic: it will greedily create matches regardless of the class labels.

The algorithm can be tuned to classify true positives between certain classes, but not others. This is useful if the labels in your ground truth do not match the exact strings of your model predictions, or if you want to associate multiple predictions with one ground truth label, or multiple ground truth labels with one prediction. To recompute metrics based on different matching, you can re-commit the run with new request parameters.


## OpenAPI

````yaml openapi/nucleus.json POST /dataset/{dataset_id}/model/{model_id}/calculateEvaluationMetrics
openapi: 3.1.0
info:
  title: Nucleus API
  version: '1.1'
servers:
  - url: https://api.scale.com/v1/nucleus
security:
  - sec0: []
paths:
  /dataset/{dataset_id}/model/{model_id}/calculateEvaluationMetrics:
    post:
      summary: Calculate Model Metrics
      operationId: calculate-model-metrics
      parameters:
        - name: dataset_id
          in: path
          description: The Scale-generated ID of the Dataset.
          schema:
            type: string
          required: true
        - name: model_id
          in: path
          description: The Scale-generated ID of the Model.
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                allowed_label_matches:
                  type: array
                  description: >-
                    Optional list of `AllowedMatch` objects to specify allowed
                    matches for ground truth Annotations and Model Predictions.
                  items:
                    properties:
                      ground_truth_label:
                        type: string
                        description: >-
                          Label of the ground truth annotation to match with the
                          `model_prediction_label`.
                      model_prediction_label:
                        type: string
                        description: >-
                          Label of the model prediction to match with the
                          `ground_truth_label`.
                    required:
                      - ground_truth_label
                      - model_prediction_label
                    type: object
                class_agnostic:
                  type: boolean
                  default: true
                  description: >-
                    If `true` (default), matches are created regardless of class
                    labels. Set to `false` when supplying
                    `allowed_label_matches`.
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value: {}
              schema:
                type: object
                properties: {}
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  value: {}
              schema:
                type: object
                properties: {}
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: http
      scheme: basic

````