Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте R² Score | Regression Metrics
Evaluation Metrics in Machine Learning

bookR² Score

The R² score, also called the coefficient of determination, is a key metric for evaluating regression models. It measures the proportion of the variance in the dependent variable that is predictable from the independent variables. Building on concepts like MSE, RMSE, and MAE, which quantify average error, the R² score provides a normalized measure of how well your model explains the observed outcomes compared to a simple mean prediction.

The formula for is:

R2=1i=1n(yiy^i)2i=1n(yiyˉ)2R^2 = 1 - \frac{\sum_{i=1}^n (y_i - \hat{y}_i)^2}{\sum_{i=1}^n (y_i - \bar{y})^2}
  • yiy_i: true values;
  • y^i\hat{y}_i: predicted values;
  • yˉ\bar{y}: mean of the true values.

The numerator represents the sum of squared errors of the model, while the denominator is the total variance in the data. An R² value of 1 means perfect prediction; 0 means the model is no better than always predicting the mean; negative values indicate the model performs worse than simply using the mean.

123456789
from sklearn.metrics import r2_score # Example true values and predictions y_true = [3, -0.5, 2, 7] y_pred = [2.5, 0.0, 2, 8] # Calculate R² score r2 = r2_score(y_true, y_pred) print(f"R² score: {r2:.2f}")
copy

Interpreting R² Values and Understanding Limitations

Interpreting R² values helps you understand model performance in context:

  • An R² score close to 1 means your model explains most of the variance in the target variable;
  • A score near 0 shows the model does not improve over simply predicting the mean;
  • Negative values indicate your model performs worse than always predicting the mean.

However, R² has important limitations:

  • It does not show whether your predictions are biased;
  • It cannot detect overfitting or model complexity issues;
  • It may be misleading when comparing models with different numbers of features or on data with outliers.

Always use alongside other regression metrics and validation strategies to get a complete and reliable assessment of your model's quality.

question mark

Which statement about the R² score is correct according to the chapter content?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 3

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Awesome!

Completion rate improved to 6.25

bookR² Score

Свайпніть щоб показати меню

The R² score, also called the coefficient of determination, is a key metric for evaluating regression models. It measures the proportion of the variance in the dependent variable that is predictable from the independent variables. Building on concepts like MSE, RMSE, and MAE, which quantify average error, the R² score provides a normalized measure of how well your model explains the observed outcomes compared to a simple mean prediction.

The formula for is:

R2=1i=1n(yiy^i)2i=1n(yiyˉ)2R^2 = 1 - \frac{\sum_{i=1}^n (y_i - \hat{y}_i)^2}{\sum_{i=1}^n (y_i - \bar{y})^2}
  • yiy_i: true values;
  • y^i\hat{y}_i: predicted values;
  • yˉ\bar{y}: mean of the true values.

The numerator represents the sum of squared errors of the model, while the denominator is the total variance in the data. An R² value of 1 means perfect prediction; 0 means the model is no better than always predicting the mean; negative values indicate the model performs worse than simply using the mean.

123456789
from sklearn.metrics import r2_score # Example true values and predictions y_true = [3, -0.5, 2, 7] y_pred = [2.5, 0.0, 2, 8] # Calculate R² score r2 = r2_score(y_true, y_pred) print(f"R² score: {r2:.2f}")
copy

Interpreting R² Values and Understanding Limitations

Interpreting R² values helps you understand model performance in context:

  • An R² score close to 1 means your model explains most of the variance in the target variable;
  • A score near 0 shows the model does not improve over simply predicting the mean;
  • Negative values indicate your model performs worse than always predicting the mean.

However, R² has important limitations:

  • It does not show whether your predictions are biased;
  • It cannot detect overfitting or model complexity issues;
  • It may be misleading when comparing models with different numbers of features or on data with outliers.

Always use alongside other regression metrics and validation strategies to get a complete and reliable assessment of your model's quality.

question mark

Which statement about the R² score is correct according to the chapter content?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 3
some-alt