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

Skip to content

[MRG] Fast PDP for DecisionTreeRegressor and RandomForestRegressor #15864

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 33 commits into from
Feb 24, 2020

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Dec 11, 2019

This PR implements the fast 'recursion' method for DecisionTreeRegressor and RandomForestRegressor

Need to merge #16114 first

We're only exposing the method which already exists for the gradient boosting estimators.

@NicolasHug
Copy link
Member Author

Codecov is red because of assert _IS_32BIT which isn't hit. Can be safely ignored.

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 think this is good. I am just wondering about duck-typing the estimator supporting the recursion. It could be handy.

@@ -351,19 +339,25 @@ def partial_dependence(estimator, X, features, response_method='auto',
if (isinstance(estimator, BaseGradientBoosting) and
estimator.init is None):
method = 'recursion'
elif isinstance(estimator, BaseHistGradientBoosting):
elif isinstance(estimator, (BaseHistGradientBoosting,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think that it would make sense to avoid this isinstance and check for hasattr(estimator, 'compute_partial_dependence') or a method that could be shared across all these estimators?

I could think that library as xgboost or lightgbm or tree base could expose the same method without us checking for type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a nice idea but that means we need to support a new public API, i.e. the interface of _compute_partial_dependence_recursion would now be fixed

We would also still need to hardcoded list of supported estimators for the error message.

Maybe we can keep that in mind for later?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep we could check how other libraries are exposing this and put all these info in an issue

@NicolasHug
Copy link
Member Author

Does this have your +1 @glemaitre ? I think all comments were addressed

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.

LGTM.

@jnothman jnothman merged commit 9412f50 into scikit-learn:master Feb 24, 2020
@jnothman
Copy link
Member

thanks @NicolasHug

panpiort8 pushed a commit to panpiort8/scikit-learn that referenced this pull request Mar 3, 2020
gio8tisu pushed a commit to gio8tisu/scikit-learn that referenced this pull request May 15, 2020
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.

4 participants