8000 Number of features constant property · Issue #13599 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Number of features constant property #13599

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

Closed
RomainCendre opened this issue Apr 9, 2019 · 3 comments
Closed

Number of features constant property #13599

RomainCendre opened this issue Apr 9, 2019 · 3 comments

Comments

@RomainCendre
Copy link

Hi everyone,
I was playing (as most of mytime) with your awesome library, and I was wondering I that possible and a good idea to have a constant property to get the number of features a model was fit for, irrespective of the model?

Here is an example, sometimes I use Pipeline using PCA reduction and SVM with coefficients for wanted explained variance, but here I get a multiple possible output size that depend of my input data.

I like to produce report that detail whats happening in pipe: so I designed a function like that return these property base on wich kind of model. But it need to be done for each type of existing model.

    def __number_of_features(model):
        if isinstance(model, Pipeline):
            model = model.steps[-1][1]

        if isinstance(model, SVC):
            return model.coef_.shape[1]

        return 0

Just an idea I got in mind, and to blocking.
Feel free to decide if it's relevant or not.

@jnothman
Copy link
Member
jnothman commented Apr 9, 2019 via email

@RomainCendre
Copy link
Author

Oh I didn't see it in current issues :'(
Thank you for your answer, that's a good news! =)

@thomasjpfan
Copy link
Member

With SLEP010 all estimators now have a n_features_in_ which represents how many features a model was trained on.

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

No branches or pull requests

3 participants
0