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
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
.
Feel free to fork the model and add your own suggestiongs.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/YourGreatFeature
) - Commit your Changes (
git commit -m 'Add some YourGreatFeature'
) - Push to the Branch (
git push origin feature/YourGreatFeature
) - Open a Pull Request
If you have any question, feel free to reach me out at:
- Medium
- Email: [email protected]
Distributed under the MIT License. See LICENSE.md
for more information.