均方根误差#
- sklearn.metrics.root_mean_squared_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')[source]#
- 均方根误差回归损失。 - 更多信息请参见 用户指南。 - 1.4版本新增。 - 参数:
- y_truearray-like of shape (n_samples,) or (n_samples, n_outputs)
- 真实目标值。 
- y_predarray-like of shape (n_samples,) or (n_samples, n_outputs)
- 预测目标值。 
- sample_weightarray-like of shape (n_samples,), default=None
- 样本权重。 
- multioutput{'raw_values', 'uniform_average'} 或 shape 为 (n_outputs,) 的数组,默认值为 'uniform_average'
- 定义多个输出值的聚合方式。数组类型的值定义用于平均误差的权重。 - ‘raw_values’
- 在多输出输入的情况下返回完整的误差集。 
- ‘uniform_average’
- 所有输出的误差以统一权重进行平均。 
 
 
- 返回:
- loss浮点数或浮点数 ndarray
- 一个非负浮点值(最佳值为 0.0),或一个浮点值数组,每个值对应一个单独的目标。 
 
 - 示例 - >>> from sklearn.metrics import root_mean_squared_error >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> root_mean_squared_error(y_true, y_pred) 0.612... >>> y_true = [[0.5, 1],[-1, 1],[7, -6]] >>> y_pred = [[0, 2],[-1, 2],[8, -5]] >>> root_mean_squared_error(y_true, y_pred) 0.822... 
 
     
