Skip to main content

R2

Metric
DashAI.back.metrics.regression.R2

Coefficient of determination — goodness of fit for regression models.

R² (R-squared) measures the proportion of variance in the target variable that is explained by the model. It compares the model's predictions to a trivial baseline that always predicts the target mean. An R² of 1.0 means the model explains all variance perfectly; 0.0 means it is no better than the mean predictor; negative values indicate worse-than-baseline performance.

R² is scale-invariant (unlike MAE/MSE), making it easy to compare models trained on targets with different units or magnitudes.

::

R²(y, ŷ) = 1 - Σᵢ(yᵢ - ŷᵢ)² / Σᵢ(yᵢ - ȳ)²

Range: (-∞, 1], higher is better (MAXIMIZE = True).

References

Methods

score(true_values: 'DashAIDataset', pred_values: 'np.ndarray') -> float

Defined on R2

Calculate the R2 score between true values and predicted values.

Parameters

true_values : DashAIDataset
A DashAI dataset with true values.
predicted_values : np.ndarray
A one-dimensional array with the predicted values for each instance.

Returns

float
R2 score between true values and predicted values

get_metadata(cls: 'BaseMetric') -> Dict[str, Any]

Defined on BaseMetric

Get metadata values for the current metric.

Returns

Dict[str, Any]
Dictionary with the metadata

Compatible with