Skip to content

Extracting features importance #71

@faisalaleissa

Description

@faisalaleissa
  • MLBlocks version: '0.2.0'
  • Python version: Python 3.6.3
  • Operating System: MacOS High Sierra

Description

I have been trying to produce the features importance from a classifier (RandomForrest). The feature_importances function doesn't take arguments. So, the MLPipeline doesn't execute (TypeError: 'numpy.ndarray' object is not callable).

What I Did

I left the arguments empty in the primitive definition file in the produce part.


{
    "name": "sklearn.ensemble.RandomForestClassifier1",
    "documentation": "http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html",
    "description": "Scikit-learn RandomForestClassifier.",
    "classifiers": {
        "type": "estimator",
        "subtype": "classifier"
    },
    "modalities": [],
    "primitive": "sklearn.ensemble.RandomForestClassifier",
    "fit": {
        "method": "fit",
        "args": [
            {
                "name": "X",
                "type": "DataFrame"
            },
            {
                "name": "y",
                "type": "Series"
            }
        ]
    },
    "produce": {
        "method": "feature_importances_",
        "args": [],
        "output": [
            {
                "name": "y",
                "type": "Series"
            }
        ]
    },
    "hyperparameters": {
        "fixed": {
            "n_jobs": {
                "type": "int",
                "default": -1
            }
        },
        "tunable": {
            "criterion": {
                "type": "str",
                "default": "entropy",
                "values": ["entropy", "gini"]
            },
            "max_features": {
                "type": "str",
                "default": null,
                "range": [null, "auto", "log2"]
            },
            "max_depth": {
                "type": "int",
                "default": 10,
                "range": [1, 30]
            },
            "min_samples_split": {
                "type": "float",
                "default": 0.1,
                "range": [0.0001, 0.5]
            },
            "min_samples_leaf": {
                "type": "float",
                "default": 0.1,
                "range": [0.0001, 0.5]
            },
            "n_estimators": {
                "type": "int",
                "default": 30,
                "values": [2, 500]
            },
            "class_weight": {
                "type": "str",
                "default": null,
                "range": [null, "balanced"]
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions