### Regression Metrics¶

• multiword controls how scores or losses are calculated:

• 'uniform_average' (default): uses a uniform mean.
• ndarray of (weights): weighted average
• 'raw_values': unchanged values returned as an array
• r2_score and explained_variance_score also accept multioutput="variance_weighted" for weighing the outputs.

### Explained Variance¶

• $explained\_{}variance(y, \hat{y}) = 1 - \frac{Var\{ y - \hat{y}\}}{Var\{y\}}$.

• 1.0 is best possible score. Lower numbers are worse.

### Max Error¶

• Returns a maximum residual error (between prediction and true value). Should return 0 in perfectly fitted model's training set.

• $\text{Max Error}(y, \hat{y}) = max(| y_i - \hat{y}_i |)$

• Multioutputs are not supported.

### Mean Absolute Error (MAE)¶

• MAE corresponds to the expected L1-norm loss.

• $\text{MAE}(y, \hat{y}) = \frac{1}{n_{\text{samples}}} \sum_{i=0}^{n_{\text{samples}}-1} \left| y_i - \hat{y}_i \right|.$

### Mean Squared Error (MSE)¶

• MSE corresponds to the expected squared (quadratic) loss.

• $\text{MSE}(y, \hat{y}) = \frac{1}{n_\text{samples}} \sum_{i=0}^{n_\text{samples} - 1} (y_i - \hat{y}_i)^2.$

### Mean Squared Log Error (MSLE)¶

• This metric is preferred when measuring exponential growth variables (populations, commodity sales over time, ...). It penalizes under-predicted estimates more than over-predicted ones.

• $\text{MSLE}(y, \hat{y}) = \frac{1}{n_\text{samples}} \sum_{i=0}^{n_\text{samples} - 1} (\log_e (1 + y_i) - \log_e (1 + \hat{y}_i) )^2.$

### Mean Absolute Pct Error (MAPE)¶

• Also called mean absolute percentage deviation (MAPD).

• Sensitive to relative errors; not affected by a global scaling of the target variable.

• $\text{MAPE}(y, \hat{y}) = \frac{1}{n_{\text{samples}}} \sum_{i=0}^{n_{\text{samples}}-1} \frac{{}\left| y_i - \hat{y}_i \right|}{max(\epsilon, \left| y_i \right|)}$

• Supports multiple output problems.

### R^2 score (coefficient of determination)¶

• Represents the proportion of variance (of y) that is explained by the independent variables in the model. It is an indication of goodness of fit - therefore, a measure of how well unseen samples are likely to be predicted by the model.

• Variance is dataset dependent - so R² may not be comparable across different datasets. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R² score of 0.0.

• $R^2(y, \hat{y}) = 1 - \frac{\sum_{i=1}^{n} (y_i - \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i - \bar{y})^2}$

### Tweedie Deviances¶

• Returns a mean Tweedie deviance error based on a power parameter:

• Gamma distribution with power=2 means that simultaneously scaling y_true and y_pred has no effect on the deviance.

• Poisson distribution power=1 the deviance scales linearly.