8000 FIX bug in SplineTransformer.n_features_out_ by mlondschien · Pull Request #19577 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX bug in SplineTransformer.n_features_out_ #19577

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

Conversation

mlondschien
Copy link
Contributor

Reference Issues/PRs

Found this while working on #19483 extending #18368 (@lorentzenchr).

What does this implement/fix? Explain your changes.

The n_features_out_ attribute of the SplineTransformer is currently incorrect. On master:

In [1]: from sklearn.preprocessing import SplineTransformer
   ...: import numpy as np
   ...: 
   ...: X=np.linspace(0, 1, 10)[:, None]
   ...: transformer = SplineTransformer(
   ...:     n_knots=3,
   ...:     degree=3,
   ...:     include_bias=False
   ...: )
   ...: 
   ...: transformer.fit(X)
   ...: transformer.n_features_out_
Out[1]: 5

In [2]: transformer.transform(X).shape
Out[2]: (10, 4)

See also the added test.

Copy link
Member
@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member
@lorentzenchr lorentzenchr left a comment

Choose a reason for hiding this comment

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

LGTM. Good catch!

@lorentzenchr lorentzenchr changed the title Fix bug in SplineTransformer.n_features_out_ FIX bug in SplineTransformer.n_features_out_ Feb 27, 2021
@lorentzenchr lorentzenchr merged commit f0a6f05 into scikit-learn:main Feb 27, 2021
@mlondschien mlondschien deleted the spline-transformer-n-features-out branch February 27, 2021 13:02
@glemaitre glemaitre mentioned this pull request Apr 22, 2021
12 tasks
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
0