-
-
Notifications
You must be signed in to change notification settings - Fork 26k
DOC Fix FutureWarning in ensemble/plot_gradient_boosting_regularization.html #24960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC Fix FutureWarning in ensemble/plot_gradient_boosting_regularization.html #24960
Conversation
@@ -76,7 +79,7 @@ | |||
|
|||
for i, y_pred in enumerate(clf.staged_decision_function(X_test)): | |||
# clf.loss_ assumes that y_test[i] in {0, 1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
@@ -76,7 +79,7 @@ | |||
|
|||
for i, y_pred in enumerate(clf.staged_decision_function(X_test)): | |||
# clf.loss_ assumes that y_test[i] in {0, 1} | |||
test_deviance[i] = clf.loss_(y_test, y_pred) | |||
test_deviance[i] = binomial_deviance(y_test, y_pred.ravel()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we can use staged_predict_proba
directly:
for i, y_proba in enumerate(clf.staged_predict_proba(X_test)):
test_deviance[i] = 2 * log_loss(y_test, y_proba[:, 1])
def binomial_deviance(y, raw_predictions): | ||
return -2 * np.mean((y * raw_predictions) - np.logaddexp(0, raw_predictions)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this function and we will use the log_loss
.
@@ -48,6 +48,9 @@ | |||
"min_samples_split": 5, | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import the log loss after line 34:
from sklearn.metrics import log_loss
@@ -91,3 +94,4 @@ | |||
plt.ylabel("Test Set Deviance") | |||
|
|||
plt.show() | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure that we need this additional line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed the small fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR feels like dejavu. LGTM though
Indeed. |
Thanks @Reddragonemperor58 |
Reference Issues/PRs
Related to #24876
What does this implement/fix? Explain your changes.
Fix FutureWarning in ensemble/plot_gradient_boosting_regularization.html
Any other comments?