mean_gamma_deviance#

sklearn.metrics.mean_gamma_deviance(y_true, y_pred, *, sample_weight=None)[source]#

平均 Gamma 偏差回归损失。

Gamma 偏差与幂参数 power=2 的 Tweedie 偏差等效。它对于目标变量的缩放是不变的,并测量相对误差。

用户指南中了解更多信息。

参数:
y_true形状为 (n_samples,) 的 array-like

真实(正确)目标值。要求 y_true > 0。

y_pred形状为 (n_samples,) 的类数组

估计的目标值。要求 y_pred > 0。

sample_weightshape 为 (n_samples,) 的 array-like, default=None

样本权重。

返回:
loss浮点数

一个非负浮点值(最佳值为 0.0)。

示例

>>> from sklearn.metrics import mean_gamma_deviance
>>> y_true = [2, 0.5, 1, 4]
>>> y_pred = [0.5, 0.5, 2., 2.]
>>> mean_gamma_deviance(y_true, y_pred)
1.0568...