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

Skip to content

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?

test_deviance = np.zeros((params["n_estimators"],), dtype=np.float64)

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

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.

"random_state": 2,
"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

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