10 Regression Metrics Data Scientist Must Know (Python-Sklearn Code Included)
import numpy as np
from sklearn.metrics import *
Python Functions
- 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…