mean_pinball_loss#
- sklearn.metrics.mean_pinball_loss(y_true, y_pred, *, sample_weight=None, alpha=0.5, multioutput='uniform_average')[source]#
分位数回归的 Pinball loss。
Read more in the User Guide.
- 参数:
- y_true形状为 (n_samples,) 或 (n_samples, n_outputs) 的类数组对象
真实(正确)的目标值。
- y_pred形状为 (n_samples,) 或 (n_samples, n_outputs) 的类数组对象
估计的目标值。
- sample_weightshape 为 (n_samples,) 的 array-like, default=None
样本权重。
- alphafloat, slope of the pinball loss, default=0.5,
This loss is equivalent to Mean absolute error when
alpha=0.5,alpha=0.95is minimized by estimators of the 95th percentile.- multioutput{‘raw_values’, ‘uniform_average’} 或形状为 (n_outputs,) 的类数组对象, default=’uniform_average’
定义了多输出值聚合的方式。类数组值定义了用于平均误差的权重。
- ‘raw_values’
在多输出输入情况下返回完整的误差集。
- ‘uniform_average’
所有输出的误差以统一权重进行平均。
- 返回:
- lossfloat or ndarray of floats
If multioutput is ‘raw_values’, then mean absolute error is returned for each output separately. If multioutput is ‘uniform_average’ or an ndarray of weights, then the weighted average of all output errors is returned.
The pinball loss output is a non-negative floating point. The best value is 0.0.
示例
>>> from sklearn.metrics import mean_pinball_loss >>> y_true = [1, 2, 3] >>> mean_pinball_loss(y_true, [0, 2, 3], alpha=0.1) 0.03... >>> mean_pinball_loss(y_true, [1, 2, 4], alpha=0.1) 0.3... >>> mean_pinball_loss(y_true, [0, 2, 3], alpha=0.9) 0.3... >>> mean_pinball_loss(y_true, [1, 2, 4], alpha=0.9) 0.03... >>> mean_pinball_loss(y_true, y_true, alpha=0.1) 0.0 >>> mean_pinball_loss(y_true, y_true, alpha=0.9) 0.0