sklearn.metrics.mean_squared_error

Mean square error regression loss
format:
sklearm.mean_squared_error (y_true, y_pred, sample_weight=None, multioutput= ‘uniform_average’)
parameter:
y_true: true value.
y_pred: predicted value.
sample_weight: sample weight.
multioutput: multi-dimensional input and output, default is’ uniform_average ‘, calculates the mean square error of all elements, returns as a scalar; Alternatively, ‘raw_values’ computes the mean square error of the corresponding column and returns a one-dimensional array with the same number of columns.
example:

from sklearn.metrics import mean_squared_error
y_true = [3, -1, 2, 7]
y_pred = [2, 0.0, 2, 8]
mean_squared_error(y_true, y_pred)
# Output: 0.75
y_true = [[0.5, 1],[-1, 1],[7, -6]]
y_pred = [[0, 2],[-1, 2],[8, -5]]
mean_squared_error(y_true, y_pred)
# Output: 0.7083333333333334
mean_squared_error(y_true, y_pred, multioutput='raw_values')
# Output: array([0.41666667, 1.        ])
mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7])
# Output: 0.825
# multioutput=[0.3, 0.7]返回将array([0.41666667, 1.        ])按照0.3*0.41666667+0.7*1.0计算所得的结果
mean_squared_error(y_true, y_pred, multioutput='uniform_average')
# Output: 0.7083333333333334

Refer to the link: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html

Read More: