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
Closed
@RomainCendre

Description

@RomainCendre

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0