What do we use instead of the deprecated GradientBoostingClassifier._loss?

Viewed 37
1 Answers

When loss is the default (log_loss), one can recover deviance like this:

def sigmoid(z):
    "Convert log odds to probabilities."
    # https://stackoverflow.com/q/60746851/850781
    return 1/(1 + np.exp(-z))

GBC = GradientBoostingClassifier(...)
GBC.fit(X, y)
for y_pred in GBC.staged_decision_function(X_test):
    assert math.isclose(GBC.loss_(y_test, y_pred) / 2,
                        sklearn.metrics.log_loss(y_test, sigmoid(y_pred)))

However, the arbitrary loss case is still missing.

Related