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

# Mean absolute percentage error (MAPE)

> Learn how to use the mean absolute percentage error test

## Definition

The mean absolute percentage error (MAPE) test measures the average of the absolute percentage differences between the predicted values and the true values. MAPE expresses prediction accuracy as a percentage, making it scale-independent and easily interpretable.

## Taxonomy

* **Task types**: Tabular regression.
* **Availability**: development (Continuously evaluate your models and datasets as you iterate on their versions.)
  and monitoring (Monitor a model in production, measure its health, check for drifts and set up alerts.).

## Why it matters

* MAPE provides a percentage-based measure of prediction accuracy that is easy to interpret and communicate to stakeholders.
* Being scale-independent, MAPE allows for comparison of model performance across different datasets and target variables.
* Lower MAPE values indicate better model performance, with 0% representing perfect predictions.
* MAPE is particularly useful when the relative size of errors is more important than their absolute magnitude.

## Required columns

To compute this metric, your dataset must contain the following columns:

* **Predictions**: The predicted values from your regression model
* **Ground truths**: The actual/true target values

> [!NOTE]
>
> MAPE is undefined when true values are zero, as this would result in division
> by zero. Consider using alternative metrics like MAE when your dataset
> contains zero values.

## Test configuration examples

If you are writing a `tests.json`, here are a few valid configurations for the MAPE test:

```json Development theme={null}
[
  {
    "name": "MAPE below 10%",
    "description": "Ensure that the mean absolute percentage error is below 10%",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "mape",
        "operator": "<",
        "value": 0.1
      }
    ],
    "subpopulationFilters": null,
    "mode": "development",
    "usesValidationDataset": true,
    "usesTrainingDataset": false,
    "usesMlModel": true,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

```json Monitoring theme={null}
[
  {
    "name": "MAPE below 10%",
    "description": "Ensure that the mean absolute percentage error is below 10%",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "mape",
        "operator": "<",
        "value": 0.1
      }
    ],
    "subpopulationFilters": null,
    "mode": "monitoring",
    "usesProductionData": true,
    "evaluationWindow": 3600,
    "delayWindow": 0,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

## Related

* [MSE test](https://docs.openlayer.com/tests/catalog/mse.md) - Mean squared error.
* [RMSE test](https://docs.openlayer.com/tests/catalog/rmse.md) - Root mean squared error.
* [MAE test](https://docs.openlayer.com/tests/catalog/mae.md) - Mean absolute error (alternative when zero values present).
* [R-squared test](https://docs.openlayer.com/tests/catalog/r2.md) - Coefficient of determination.
* [Aggregate metrics](https://docs.openlayer.com/tests/performance/aggregate-metrics) - Overview of all available metrics.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.