均方根误差(RMSE)是一种衡量回归模型性能的指标,其计算公式为:

其中, 是真实值, 是预测值。

标准代码如下

def rmse(y_true, y_pred):
    return round(np.sqrt(np.mean((y_true - y_pred) ** 2)), 3)