8000 DOC Fix FutureWarning in ensemble/plot_gradient_boosting_oob.py by MaximSmolskiy · Pull Request #24948 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Fix FutureWarning in ensemble/plot_gradient_boosting_oob.py #24948

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

Conversation

MaximSmolskiy
Copy link
Contributor
@MaximSmolskiy MaximSmolskiy commented Nov 15, 2022

Reference Issues/PRs

Related to #24876

What does this implement/fix? Explain your changes.

Fix FutureWarnings in ensemble/plot_gradient_boosting_oob.py

/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?

@glemaitre
Copy link
Member

I reopen this PR because we need to fix this example. But we need to make some tweaks.
The log_loss expect probabilities between 0 and 1 and will clip them. The binomial deviance works with raw predictions from the decision function. We need to create a function computing those on the raw predictions then:

def binomial_deviance(y, raw_predictions):
    return -2 * np.mean(
        (y * raw_predictions) - np.logaddexp(0, raw_predictions)
    )

and we can then call

score[i] = binomial_deviance(y_test, y_pred.ravel())

and we will get the same plot.

@glemaitre
Copy link
Member

LGTM Thanks @MaximSmolskiy

@glemaitre glemaitre merged commit 2c1581c into scikit-learn:main Nov 16, 2022
@MaximSmolskiy MaximSmolskiy deleted the doc-fix-FutureWarning-in-ensemble/plot_gradient_boosting_oob.html branch November 16, 2022 10:09
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.

2 participants
0