Python implementation of R package breakDown

Overview

pyBreakDown

Python implementation of breakDown package (https://github.com/pbiecek/breakDown).

Docs: https://pybreakdown.readthedocs.io.

Requirements

Nothing fancy, just python 3.5.2+ and pip.

Installation

Install directly from github

    git clone https://github.com/bondyra/pyBreakDown
    cd ./pyBreakDown
    python3 setup.py install  # (or use pip install . instead)

Basic usage

Load dataset

from sklearn import datasets
x = datasets.load_boston()
data = x.data
feature_names = x.feature_names
y = x.target

Prepare model

import numpy as np
from sklearn import tree
model = tree.DecisionTreeRegressor()

Train model

train_data = data[1:300,:]
train_labels=y[1:300]
model = model.fit(train_data,y=train_labels)

Explain predictions on test data

#necessary imports
from pyBreakDown.explainer import Explainer
from pyBreakDown.explanation import Explanation
#make explainer object
exp = Explainer(clf=model, data=train_data, colnames=feature_names)
#make explanation object that contains all information
explanation = exp.explain(observation=data[302,:],direction="up")

Text form of explanations

#get information in text form
explanation.text()
Feature                  Contribution        Cumulative          
Intercept = 1            29.1                29.1                
RM = 6.495               -1.98               27.12               
TAX = 329.0              -0.2                26.92               
B = 383.61               -0.12               26.79               
CHAS = 0.0               -0.07               26.72               
NOX = 0.433              -0.02               26.7                
RAD = 7.0                0.0                 26.7                
INDUS = 6.09             0.01                26.71               
DIS = 5.4917             -0.04               26.66               
ZN = 34.0                0.01                26.67               
PTRATIO = 16.1           0.04                26.71               
AGE = 18.4               0.06                26.77               
CRIM = 0.09266           1.33                28.11               
LSTAT = 8.67             4.6                 32.71               
Final prediction                             32.71               
Baseline = 0
#customized text form
explanation.text(fwidth=40, contwidth=40, cumulwidth = 40, digits=4)
Feature                                 Contribution                            Cumulative                              
Intercept = 1                           29.1                                    29.1                                    
RM = 6.495                              -1.9826                                 27.1174                                 
TAX = 329.0                             -0.2                                    26.9174                                 
B = 383.61                              -0.1241                                 26.7933                                 
CHAS = 0.0                              -0.0686                                 26.7247                                 
NOX = 0.433                             -0.0241                                 26.7007                                 
RAD = 7.0                               0.0                                     26.7007                                 
INDUS = 6.09                            0.0074                                  26.708                                  
DIS = 5.4917                            -0.0438                                 26.6642                                 
ZN = 34.0                               0.0077                                  26.6719                                 
PTRATIO = 16.1                          0.0385                                  26.7104                                 
AGE = 18.4                              0.0619                                  26.7722                                 
CRIM = 0.09266                          1.3344                                  28.1067                                 
LSTAT = 8.67                            4.6037                                  32.7104                                 
Final prediction                                                                32.7104                                 
Baseline = 0

Visual form of explanations

explanation.visualize()

png

#customize height, width and dpi of plot
explanation.visualize(figsize=(8,5),dpi=100)

png

#for different baselines than zero
explanation = exp.explain(observation=data[302,:],direction="up",useIntercept=True)  # baseline==intercept
explanation.visualize(figsize=(8,5),dpi=100)

png

Owner
MI^2 DataLab
MI^2 DataLab
Many Class Activation Map methods implemented in Pytorch for CNNs and Vision Transformers. Including Grad-CAM, Grad-CAM++, Score-CAM, Ablation-CAM and XGrad-CAM

Class Activation Map methods implemented in Pytorch pip install grad-cam ⭐ Comprehensive collection of Pixel Attribution methods for Computer Vision.

Jacob Gildenblat 6.5k Jan 01, 2023
Code for "High-Precision Model-Agnostic Explanations" paper

Anchor This repository has code for the paper High-Precision Model-Agnostic Explanations. An anchor explanation is a rule that sufficiently β€œanchors”

Marco Tulio Correia Ribeiro 735 Jan 05, 2023
πŸ‘‹πŸ¦Š Xplique is a Python toolkit dedicated to explainability, currently based on Tensorflow.

πŸ‘‹πŸ¦Š Xplique is a Python toolkit dedicated to explainability, currently based on Tensorflow.

DEEL 343 Jan 02, 2023
pytorch implementation of "Distilling a Neural Network Into a Soft Decision Tree"

Soft-Decision-Tree Soft-Decision-Tree is the pytorch implementation of Distilling a Neural Network Into a Soft Decision Tree, paper recently published

Kim Heecheol 262 Dec 04, 2022
Logging MXNet data for visualization in TensorBoard.

Logging MXNet Data for Visualization in TensorBoard Overview MXBoard provides a set of APIs for logging MXNet data for visualization in TensorBoard. T

Amazon Web Services - Labs 327 Dec 05, 2022
GNNLens2 is an interactive visualization tool for graph neural networks (GNN).

GNNLens2 is an interactive visualization tool for graph neural networks (GNN).

Distributed (Deep) Machine Learning Community 143 Jan 07, 2023
Code for visualizing the loss landscape of neural nets

Visualizing the Loss Landscape of Neural Nets This repository contains the PyTorch code for the paper Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer

Tom Goldstein 2.2k Dec 30, 2022
Summary Explorer is a tool to visually explore the state-of-the-art in text summarization.

Summary Explorer is a tool to visually explore the state-of-the-art in text summarization.

Webis 42 Aug 14, 2022
Visualizer for neural network, deep learning, and machine learning models

Netron is a viewer for neural network, deep learning and machine learning models. Netron supports ONNX (.onnx, .pb, .pbtxt), Keras (.h5, .keras), Tens

Lutz Roeder 20.9k Dec 28, 2022
Visualization Toolbox for Long Short Term Memory networks (LSTMs)

Visualization Toolbox for Long Short Term Memory networks (LSTMs)

Hendrik Strobelt 1.1k Jan 04, 2023
Contrastive Explanation (Foil Trees), developed at TNO/Utrecht University

Contrastive Explanation (Foil Trees) Contrastive and counterfactual explanations for machine learning (ML) Marcel Robeer (2018-2020), TNO/Utrecht Univ

M.J. Robeer 41 Aug 29, 2022
ModelChimp is an experiment tracker for Deep Learning and Machine Learning experiments.

ModelChimp What is ModelChimp? ModelChimp is an experiment tracker for Deep Learning and Machine Learning experiments. ModelChimp provides the followi

ModelChimp 124 Dec 21, 2022
A collection of infrastructure and tools for research in neural network interpretability.

Lucid Lucid is a collection of infrastructure and tools for research in neural network interpretability. We're not currently supporting tensorflow 2!

4.5k Jan 07, 2023
Pytorch Feature Map Extractor

MapExtrackt Convolutional Neural Networks Are Beautiful We all take our eyes for granted, we glance at an object for an instant and our brains can ide

Lewis Morris 40 Dec 07, 2022
πŸŽ† A visualization of the CapsNet layers to better understand how it works

CapsNet-Visualization For more information on capsule networks check out my Medium articles here and here. Setup Use pip to install the required pytho

Nick Bourdakos 387 Dec 06, 2022
Visual analysis and diagnostic tools to facilitate machine learning model selection.

Yellowbrick Visual analysis and diagnostic tools to facilitate machine learning model selection. What is Yellowbrick? Yellowbrick is a suite of visual

District Data Labs 3.9k Dec 30, 2022
A data-driven approach to quantify the value of classifiers in a machine learning ensemble.

Documentation | External Resources | Research Paper Shapley is a Python library for evaluating binary classifiers in a machine learning ensemble. The

Benedek Rozemberczki 187 Dec 27, 2022
TensorFlowTTS: Real-Time State-of-the-art Speech Synthesis for Tensorflow 2 (supported including English, Korean, Chinese, German and Easy to adapt for other languages)

πŸ€ͺ TensorFlowTTS provides real-time state-of-the-art speech synthesis architectures such as Tacotron-2, Melgan, Multiband-Melgan, FastSpeech, FastSpeech2 based-on TensorFlow 2. With Tensorflow 2, we c

3k Jan 04, 2023
A library that implements fairness-aware machine learning algorithms

Themis ML themis-ml is a Python library built on top of pandas and sklearnthat implements fairness-aware machine learning algorithms. Fairness-aware M

Niels Bantilan 105 Dec 30, 2022
Lucid library adapted for PyTorch

Lucent PyTorch + Lucid = Lucent The wonderful Lucid library adapted for the wonderful PyTorch! Lucent is not affiliated with Lucid or OpenAI's Clarity

Lim Swee Kiat 520 Dec 26, 2022