Mean Squared Error
Mean squared error (MSE) is a metric used to evaluate regression models. The MSE of a model is the average squared difference between actual values and predicted values over all examples.
where:
-
m
is the number of examples -
yi is the actual value of the label
of the
i
th example -
Ε·i is the predicted value of the label
of the
i
th example
The lower the MSE, the better the modelβs performance. The best possible MSE is 0.
Computing mean squared error in scikit-learn
import numpy as np
from sklearn.metrics import mean_squared_error
y_true = np.array([32, 38, 47, 58, 66, 73, 85, 91, 106, 116])
y_pred = np.array([32, 41, 50, 59, 68, 77, 86, 95, 104, 113])
mse = mean_squared_error(y_true, y_pred)
print(f"MSE: {mse:.2f}")
MSE: 6.90
This page references the following sources: