sklearn >= 0.22.0
sklearn.metrics
has a mean_squared_error
function with a squared
kwarg (defaults to True
). Setting squared
to False
will return the RMSE.
from sklearn.metrics import mean_squared_error
rms = mean_squared_error(y_actual, y_predicted, squared=False)
sklearn < 0.22.0
sklearn.metrics
has a mean_squared_error
function. The RMSE is just the square root of whatever it returns.
from sklearn.metrics import mean_squared_error
from math import sqrt
rms = sqrt(mean_squared_error(y_actual, y_predicted))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…