Skip to content
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

add feature_names_in_ and n_features_in_ attributes to dummy estimators #27937

Merged
merged 8 commits into from Jan 17, 2024

Conversation

tvdboom
Copy link
Contributor

@tvdboom tvdboom commented Dec 11, 2023

Reference Issues/PRs

Fixes #27907

What does this implement/fix? Explain your changes.

Add the attributes feature_names_in_ and n_features_in_ to the Dummy estimators.

Copy link

github-actions bot commented Dec 11, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 7166583. Link to the linter CI: here

@tvdboom
Copy link
Contributor Author

tvdboom commented Dec 11, 2023

The PR fails on a single test because the error type is now different (IndexError instead of ValueError). the test is the following:

def test_quantile_strategy_empty_train():
    est = DummyRegressor(strategy="quantile", quantile=0.4)
    with pytest.raises(ValueError):
        est.fit([], [])

Not sure if I can just change the error type in the test because I am unsure what the test is actually testing (that it fails or that a specific error is raised).

@adrinjalali
Copy link
Member

I think it'd make sense to fix the test, the behavior is now more consistent with the other estimators. It would need a changelog entry though.

Copy link
Contributor

@yuanx749 yuanx749 left a comment

Choose a reason for hiding this comment

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

Some nitpicks.

sklearn/dummy.py Outdated Show resolved Hide resolved
sklearn/dummy.py Outdated Show resolved Hide resolved
sklearn/dummy.py Outdated Show resolved Hide resolved
sklearn/dummy.py Outdated Show resolved Hide resolved
@tvdboom
Copy link
Contributor Author

tvdboom commented Dec 25, 2023

@yuanx749 can you review again?

@yuanx749
Copy link
Contributor

@yuanx749 can you review again?

I just came across this PR and think it is good. But I am not a maintainer, so you need to ask a maintainer to approve. Sorry for the confusion...

@tvdboom
Copy link
Contributor Author

tvdboom commented Dec 27, 2023

I see. @adrinjalali can you review?

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

This needs a test to make sure the attributes are correctly added to the estimator instance. Otherwise LGTM

doc/whats_new/v1.4.rst Outdated Show resolved Hide resolved
doc/whats_new/v1.4.rst Outdated Show resolved Hide resolved
Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

doc/whats_new/v1.5.rst Outdated Show resolved Hide resolved
@tvdboom
Copy link
Contributor Author

tvdboom commented Jan 16, 2024

@adrinjalali can this be merged?

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @tvdboom ! LGTM

@thomasjpfan thomasjpfan merged commit 8c95052 into scikit-learn:main Jan 17, 2024
27 checks passed
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dummy estimators don't have the feature_names_in_ nor n_features_in_ attributes
4 participants