> ## 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**: <Tooltip tip="Continuously evaluate your models and datasets as you iterate on their versions.">development</Tooltip>
  and <Tooltip tip="Monitor a model in production, measure its health, check for drifts and set up alerts.">monitoring</Tooltip>.

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

<CodeGroup>
  ```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",
          "insightParameters": null,
          "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",
          "insightParameters": null,
          "measurement": "r2",
          "operator": ">",
          "value": 0.8
        }
      ],
      "subpopulationFilters": null,
      "mode": "monitoring",
      "usesProductionData": true,
      "evaluationWindow": 3600,
      "delayWindow": 0,
      "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
    }
  ]
  ```
</CodeGroup>

## Related

* [MSE test](/tests/catalog/mse) - Mean squared error.
* [RMSE test](/tests/catalog/rmse) - Root mean squared error.
* [MAE test](/tests/catalog/mae) - Mean absolute error.
* [MAPE test](/tests/catalog/mape) - Mean absolute percentage error.
* [Aggregate metrics](/tests/performance/aggregate-metrics) - Overview of all available metrics.
