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

Skip to content

API Deprecate max_feature=auto for tree classes - #22476

Merged
jeremiedbb merged 23 commits into
scikit-learn:mainfrom
MaxwellLZH:fet/tree-deprecate-max-feature
Mar 23, 2022
Merged

API Deprecate max_feature=auto for tree classes#22476
jeremiedbb merged 23 commits into
scikit-learn:mainfrom
MaxwellLZH:fet/tree-deprecate-max-feature

Conversation

@MaxwellLZH

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

This is a fix to issue #22458 .

What does this implement/fix? Explain your changes.

This PR made the following changes:

  • Tree classes raise warnings when max_feature='auto'
  • Change ExtraTreeClassifier.max_feature default value to sqrt and ExtraTreeRegressor.max_feature default value to 1.0
  • Ignore deprecation warnings in _forest._parallel_build_trees function so we don't see repeated warning messages

Comment thread sklearn/ensemble/_forest.py Outdated
@glemaitre

Copy link
Copy Markdown
Member

You will need to add some tests to check the behaviour of the warning and catch the warnings in all tests that are expected to raise the warning.

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

Comment thread sklearn/ensemble/_forest.py Outdated
Comment thread sklearn/tree/_classes.py Outdated
Comment thread sklearn/tree/_classes.py Outdated
Comment thread sklearn/tree/_classes.py Outdated
Comment thread sklearn/tree/_classes.py Outdated
MaxwellLZH and others added 5 commits February 16, 2022 17:06
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update. The CI error comes from us during UserWarnings into errors. We likely need to add a filter warning on some test fails to filter out warning. Something like this:

pytestmark = pytest.mark.filterwarnings(

Comment thread sklearn/ensemble/_base.py
Comment thread sklearn/tree/tests/test_tree.py Outdated
Comment thread sklearn/tree/tests/test_tree.py Outdated
@MaxwellLZH

Copy link
Copy Markdown
Contributor Author

We likely need to add a filter warning on some test fails to filter out warning

Hi @thomasjpfan , it seems like the failed test cases are scattered in a lot of different files due to the wide usage of tree models.

I'm wondering if there's a way to ignore that specific warning by using a global configuration during the CI process or we need to add filterwarnings individually in all of those files.

@thomasjpfan

thomasjpfan commented Feb 17, 2022

Copy link
Copy Markdown
Member

There looks to be only 4 files with warnings. For the following files, I suggest to update max_features to not use auto:

  • sklearn/ensemble/tests/test_gradient_boosting.py
  • sklearn/inspection/tests/test_partial_dependence.py
  • sklearn/tests/test_docstring_parameters.py

For sklearn/tree/tests/test_tree.py do a pytest.mark.filterwarnings on the file.

@MaxwellLZH

Copy link
Copy Markdown
Contributor Author

I just figured that I forgot to change the default value in the __init__ function for ExtraTreeClassifier and ExtraTreeRegressor. Now it's updated.

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add an entry to the change log at doc/whats_new/v1.1.rst with tag |API|. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:.

Comment thread sklearn/tree/_classes.py
Comment thread sklearn/tree/tests/test_tree.py Outdated
Comment thread sklearn/ensemble/tests/test_gradient_boosting.py Outdated

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor comment on the whats new. Otherwise LGTM

Comment thread doc/whats_new/v1.1.rst Outdated
@jeremiedbb jeremiedbb added this to the 1.1 milestone Mar 2, 2022
@jeremiedbb jeremiedbb assigned thomasjpfan and unassigned thomasjpfan Mar 2, 2022

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @MaxwellLZH. Just a few nitpicks to help the cleaning in 1.3 and I think the deprecation warning test can be simplified.

Comment thread sklearn/ensemble/_base.py Outdated
Comment thread sklearn/ensemble/tests/test_gradient_boosting.py Outdated
Comment thread sklearn/tree/tests/test_tree.py Outdated
Comment thread sklearn/tree/tests/test_tree.py Outdated
Comment thread sklearn/tree/tests/test_tree.py Outdated
Comment thread sklearn/tree/tests/test_tree.py Outdated
Comment thread sklearn/tree/tests/test_tree.py Outdated
MaxwellLZH and others added 8 commits March 23, 2022 22:32
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks @MaxwellLZH !

@jeremiedbb
jeremiedbb merged commit e5736af into scikit-learn:main Mar 23, 2022
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Apr 6, 2022
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
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