> ## 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.

# R-squared

> Learn how to use the R-squared test

## Definition

The R-squared test measures the coefficient of determination, which quantifies the proportion of the variance in the dependent variable that is predictable from the independent variables. R-squared indicates how well the regression model explains the variability of the target variable.

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

* R-squared provides an intuitive measure of model performance as a percentage of variance explained.
* Values range from 0 to 1 (or negative for very poor models), where 1 indicates perfect prediction and 0 indicates the model performs no better than predicting the mean.
* Higher R-squared values indicate better model performance and stronger explanatory power.
* R-squared is scale-independent, making it useful for comparing models across different datasets and target variables.

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

## Test configuration examples

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

```json Development theme={null}
[
  {
    "name": "R-squared above 0.8",
    "description": "Ensure that the R-squared score is above 0.8",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "r2",
        "operator": ">",
        "value": 0.8
      }
    ],
    "subpopulationFilters": null,
    "mode": "development",
    "usesValidationDataset": true,
    "usesTrainingDataset": false,
    "usesMlModel": true,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

```json Monitoring theme={null}
[
  {
    "name": "R-squared above 0.8",
    "description": "Ensure that the R-squared score is above 0.8",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "r2",
        "operator": ">",
        "value": 0.8
      }
    ],
    "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.
* [MAPE test](https://docs.openlayer.com/tests/catalog/mape.md) - Mean absolute percentage error.
* [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.