Slide 1

Slide 1 text

Interpretable Machine Learning: Making black-box models explainable with Python! David Low Co-founder / CDS

Slide 2

Slide 2 text

Bio ● ● ● ● ●

Slide 3

Slide 3 text

● ● ○ ○ ○ ● ○ ○ Overview

Slide 4

Slide 4 text

Machine Learning is everywhere! Source: Nvidia

Slide 5

Slide 5 text

Source: xkcd

Slide 6

Slide 6 text

Is there a need to explain ML model? ● Safety Make sure the system is making sound decisions. ● Debugging Understand why a system doesn't work, so we can fix that. ● Science Enable new discovery. ● Mismatched Objectives and multi-objectives trade-offs: The system may not be optimizing the true objective. ● Legal / Ethics: Legally required to provide an explanation and/or avoid discriminate against particular groups due to bias in data.

Slide 7

Slide 7 text

EU General Data Protection Regulation (GDPR) ● Article 15 and 22 from GDPR suggest that: Customer/User has the rights to request for information/explanation pertaining to decision made by the automated system. ● Such a right would enable people to ask how a specific decision (e.g. being declined insurance or being denied a promotion) was reached.

Slide 8

Slide 8 text

A highly accurate model to classify Wolf and Husky

Slide 9

Slide 9 text

A highly accurate model BUT... ● Does the model learn the RIGHT things? The answer is “NO”. Instead of learning the appearance feature of the dogs, the model picks up the signal from the background (Snow in, this case)

Slide 10

Slide 10 text

Machine Learning Model ● ML model is a function that takes the input and produce output f(x) x (Data) y (Output)

Slide 11

Slide 11 text

Complexity of learned function 1. Linear + Monotonic function 2. Non-linear + Monotonic function 3. Non-linear + Non-monotonic function Increased complexity, hence harder to interpret... Eg of Linear model: ● Linear regression, Logistic Regression, Naives Bayes... Eg of Non-linear model ● Neural Network, Tree-based (Random Forest, Gradient Boosting)...

Slide 12

Slide 12 text

Monotonicity Non-monotonic x y Monotonic x y

Slide 13

Slide 13 text

Scope of Interpretability ● Global Interpretability ○ How do parts of the model influence predictions? ● Local Interpretability ○ Why did the model make a specific decision for an instance? ○ What factors contributed to a particular decision impacting a specific person

Slide 14

Slide 14 text

Approaches ● Interpretable Models ● Model-Agnostic Methods ○ Partial Dependence Plot (PDP) ○ Individual Conditional Expectation (ICE) ○ Feature Importance ○ Surrogate Models

Slide 15

Slide 15 text

Partial Dependence Plot (PDP) I ● Shows the marginal effect of a feature on the predicted outcome of a previously fit model ● Steps ○ Select a feature: Temperature ○ Identify a list of value for that feature: 0 to 35 Celcius ○ Iterate over the list ■ Replace Temperature one value at a time ■ Take the average of the prediction outputs ○ Repeat it for other features

Slide 16

Slide 16 text

Partial Dependence Plot (PDP) II

Slide 17

Slide 17 text

Visualize in 3D

Slide 18

Slide 18 text

Individual Conditional Expectations (ICE) ● Visualizes the dependence of the predicted response on a feature for EACH instance separately, resulting in multiple lines, one for each instance.

Slide 19

Slide 19 text

● Determined by the changes in the model’s prediction error after permuting the feature’s values ● Steps ○ For each feature ■ Replace the selected feature with noise (random) values ■ Measure the changes in prediction error ● Important feature → Decline in accuracy Less important feature → No changes / Increase of accuracy Feature Importance I

Slide 20

Slide 20 text

Feature Importance II

Slide 21

Slide 21 text

Local Interpretable Model-Agnostic Explanations (LIME) ● Local surrogate models that can explain single predictions of any black-box machine learning model ● Surrogate models are interpretable models (Linear mode / Decision Tree) that are learned on the predictions of the original black box model. ● How it works ○ Generate a artificial dataset from the example we’re going to explain. ○ Use original model to get target values for each example in a generated dataset ○ Train a new interpretable model, using generated dataset and generated labels as training data. ○ Explain the original example through weights/rules of this new model. *Prediction quality of a white-box classifier shows how well it approximates the original model. If the quality is low then explanation shouldn’t be trusted.

Slide 22

Slide 22 text

No Perfect Solution ● ● ○ ■

Slide 23

Slide 23 text

Do it with Python

Slide 24

Slide 24 text

Libraries ● Scikit-Learn ○ https://scikit-learn.org/ ● Local Interpretable Model-Agnostic Explanations (LIME) ○ https://github.com/marcotcr/lime ● ELI5 ○ https://github.com/TeamHG-Memex/eli5

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Dog Breeds Classification ● Stanford Dogs Dataset (subset of ImageNet) ○ http://vision.stanford.edu/aditya86/ImageNetDogs/ ● Summary ○ 120 dog breeds ○ Around 150 images per class ○ In total, 20580 images

Slide 27

Slide 27 text

DEMO

Slide 28

Slide 28 text

Further readings ● ○ ● ○ ● ○

Slide 29

Slide 29 text

We’re hiring Front-end Developer and SW Engineer! Send your CV to [email protected]