10 Regression Metrics Data Scientist Must Know (Python-Sklearn Code Included)

T Z J Y
5 min readNov 2, 2021
Source: Unsplash
import numpy as np
from sklearn.metrics import *

Python Functions

  1. Mean Absolute Error

Definition from Wikipedia:

Mean Absolute Error (MAE) is a measure of errors between paired observations expressing the same phenomenon. Examples of Y versus X include comparisons of predicted versus observed, subsequent time versus initial time, and one technique of measurement versus an alternative technique of measurement.

Formula:

def mae(y_true, y_pred):
"""
Mean absolute error regression loss.
Args:
y_true ([np.array]): test samples
y_pred ([np.array]): predicted samples
Returns:
[float]: mean absolute error
"""
return mean_absolute_error(y_true, y_pred)

2. Mean Square Error

Definition from Wikipedia:

Mean squared error (MSE) of an estimator measures the average of the squares of the errors — that is, the average squared difference between the estimated values and the actual value.

Formula:

def mse(y_true, y_pred):
"""
Mean squared…

--

--