Giter Site home page Giter Site logo

marginal-contribution-feature-importance's Introduction

Marginal-Contribution-Feature-Importance

source code for Marginal Contribution Importance (MCI) method published in ICML 2021.

To install the package run pip install Marginal-Contribution-Feature-Importance

To evaluate MCI an evaluator object need to be initialized. This object defines the calculation of the evaluation function ν described in the paper. To initialize an evaluator object using any scikit-learn model, use the following code (further initialization options can be found in SklearnEvaluator documentation):

from sklearn.ensemble import GradientBoostingClassifier
from mci.evaluators.sklearn_evaluator import SklearnEvaluator

model = GradientBoostingClassifier()
evaluator = SklearnEvaluator(model)

To calculate the MCI score using the permutation sampling algorithm defined in the paper, run the following code and provide the number of permutations you would like to sample (for multiprocessing with n processes call with n_processes=n):

from mci.estimators.permutation_samplling import PermutationSampling

mci_estimator = PermutationSampling(evaluator, n_permutations=2**5)

Now, to evaluate the MCI score simply call the estimator with X, y pair, where X is a dafarame of features and y is a series of label values

score = mci_estimator.mci_values(X, y)

To get the MCI scores as an array call score.mci_values and to plot the feature importance call score.plot_values()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.