Toggle Menu
Prev Up Next

scikit-learn 1.3.2
Other versions

Please cite us if you use the software.

# `sklearn.metrics`.mean_gamma_deviance

sklearn.metrics.mean_gamma_deviance(y_true, y_pred, *, sample_weight=None)

  Mean Gamma deviance regression loss.

  Gamma deviance is equivalent to the Tweedie deviance with the power parameter `power=2`. It is invariant to scaling of the target variable, and measures relative errors.

  Read more in the User Guide.

  Parameters:
    y_true array-like of shape (n_samples,)

      Ground truth (correct) target values. Requires y_true > 0.

    y_pred array-like of shape (n_samples,)

      Estimated target values. Requires y_pred > 0.

    sample_weight array-like of shape (n_samples,), default=None

      Sample weights.

  Returns:
    loss float

      A non-negative floating point value (the best value is 0.0).

  Examples

      >>> 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...