Skip to content

This repository contains an example of how to implement the shap library to interpret a machine learning model.

Notifications You must be signed in to change notification settings

FernandoLpz/SHAP-Classification-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Medium Twitter Linkedin

SHAP: Shapley Additive Explanations

This repository contains an example on how to implement the shap library to interpret a machine learning model.

If you want to know in detail how SHAP works, what its components are and how to interpret ML models with the shap library, I recommend you to take a look at the article: SHAP: Shapley Additive Explanations

Table of Contents

1. How to use

There are 2 steps that you should follow, first you have to preprocess the dataset by typing:

from src.preprocess import Data
data = Data(csv_path='data/prostate_cancer.csv')

then, for training and optimizing the classifier, you need to type:

from src.model import Classifier
classifier = Classifier(x_train=data.x_train, x_test=data.x_test, y_train=data.y_train, y_test=data.y_test)

It is important to mention that the approach shown in this repository is aligned with the examples shown in the SHAP article: Shapley Additive Explanation. Also, for ease you can use the demo implemented in the jupyter notebook shap_demo.ipynb.

4. Contributing

Feel free to fork the model and add your own suggestiongs.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/YourGreatFeature)
  3. Commit your Changes (git commit -m 'Add some YourGreatFeature')
  4. Push to the Branch (git push origin feature/YourGreatFeature)
  5. Open a Pull Request

5. Contact

If you have any question, feel free to reach me out at:

6. License

Distributed under the MIT License. See LICENSE.md for more information.

About

This repository contains an example of how to implement the shap library to interpret a machine learning model.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published