# Linear Regression

Linear regression predicts the value of a dependent variable from the value of an independent variable. It models the relationship between the variables as a linear equation, and fits a line that minimizes the differences between the predicted and actual values.

## Sampling interval

Sampling intervals are 1m, 2m, 3m, 5m, 10m, 15m, 30m, 1h, and 2h.

## Numeric parameter

Has the possible values of 1, 2, or 3.

## In Dashboards

To use `linear regression` in a dashboard, apply the following function:

```code
predict_linear( \
  ${promql} \ (1)
  ${prediction_in_seconds} \(2)
)
```

|     |     |
| --- | --- |
| **1** | `${promql}`: PromQL query to evaluate |
| **2** | `${prediction_in_seconds}`: Predicts the value of a time series the specified number of seconds in the future. |

## Limitations

- Use only with **Gauge** metric types.
- Makes assumptions regarding the linearity of the data. Exhibits problems with outliers as it attempts to "overfit" the data, making the detection inconsistent.
- Do not use with anomaly detection functions that manipulate the underlying data, as it makes anomaly detection unreliable.

## Next steps

For an in-depth discussion of linear-regression, see these external resources:

- [predict\_linear()](https://prometheus.io/docs/prometheus/latest/querying/functions/#predict_linear) from the Prometheus documentation
- [Linear Regression](https://en.wikipedia.org/wiki/Linear_regression) in Wikipedia
