Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 3 commits into from
Nov 21, 2022

Conversation

Reddragonemperor58
Copy link
Contributor

Reference Issues/PRs
Related to #24876

What does this implement/fix? Explain your changes.

Fix FutureWarning in ensemble/plot_gradient_boosting_regularization.html

/home/runner/work/scikit-learn/scikit-learn/sklearn/utils/deprecation.py:101: FutureWarning:

Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.

/home/runner/work/scikit-learn/scikit-learn/sklearn/utils/deprecation.py:101: FutureWarning:

Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.

/home/runner/work/scikit-learn/scikit-learn/sklearn/utils/deprecation.py:101: FutureWarning:

Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.

/home/runner/work/scikit-learn/scikit-learn/sklearn/utils/deprecation.py:101: FutureWarning:

Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.

/home/runner/work/scikit-learn/scikit-learn/sklearn/utils/deprecation.py:101: FutureWarning:

Attribute `loss_` was deprecated in version 1.1 and will be removed in 1.3.

Any other comments?

@@ -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}
Copy link
Member

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())
Copy link
Member

@glemaitre glemaitre Nov 16, 2022

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])

Comment on lines 51 to 53
def binomial_deviance(y, raw_predictions):
return -2 * np.mean((y * raw_predictions) - np.logaddexp(0, raw_predictions))

Copy link
Member

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,
}

Copy link
Member

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()

Copy link
Member

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.

Copy link
Member

@glemaitre glemaitre left a 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

Copy link
Member

@betatim betatim left a 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

@glemaitre
Copy link
Member

This PR feels like dejavu. LGTM though

Indeed.

@glemaitre glemaitre merged commit 75db1bc into scikit-learn:main Nov 21, 2022
@glemaitre
Copy link
Member

Thanks @Reddragonemperor58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants