Explainable AI explained! | #3 LIME

DeepFindr
25 Feb 202113:58

Summary

TLDRIn diesem Video wird LIME (Local Interpretable Model-Agnostic Explanations) vorgestellt, eine Methode zur Erklärung von Black-Box-Algorithmen. LIME ermöglicht es, lokale Erklärungen für Vorhersagen zu generieren, indem es einfache Modelle in der Umgebung eines bestimmten Datenpunkts erstellt. Diese Erklärungen helfen, die Funktionsweise komplexer Modelle besser zu verstehen und die wichtigsten Merkmale zu identifizieren. Das Video behandelt den mathematischen Optimierungsansatz von LIME und zeigt, wie es auf verschiedene Datenarten wie Tabellendaten, Bilder und Text angewendet werden kann, um Vertrauen und Verständnis für KI-Modelle zu schaffen.

Takeaways

  • 🧠 **LIME steht für Local Interpretable Model-Agnostic Explanations und ist ein Ansatz zur Erklärung von Schwarz-Kasten-Algorithmen.
  • 🌐 **LIME kann für jeden maschinellen Lernmodell verwendet werden, da es model-agnostisch ist.
  • 📈 **Die Idee hinter LIME besteht darin, die lokale Umgebung einer individuellen Vorhersage zu betrachten und dort eine einfache Erklärung zu erstellen.
  • 🔍 **LIME verwendet eine lineare, interpretierbare Modellfamilie (wie lineare Regression), um eine lokale Approximation des komplexen Modells zu schaffen.
  • 🔄 **Die Erklärungen von LIME sind lokal treu, aber sie müssen möglicherweise nicht global sinnvoll sein.
  • 🔍 **LIME arbeitet mit fast jeder Art von Eingabe, wie Text, tabellarischen Daten, Bildern oder sogar Graphen.
  • 🔧 **LIME kann dazu beitragen, das Vertrauen in Vorhersagealgorithmen zu stärken, indem es Erklärungen bereitstellt, die von Fachexperten überprüft werden können.
  • 📊 **Die mathematische Optimierung bei LIME ist intuitiv, da sie eine lokale Approximation des komplexen Modells für eine bestimmte Eingabe sucht.
  • 📈 **LIME verwendet eine Verlustfunktion, die zwei Hauptkomponenten hat: eine zur Lokaltreue und eine zur Einfachheit des Ersatzmodells.
  • 💻 **In der Praxis wird LIME oft mit regulärenisierungstechnischen Methoden wie Lasso-Linear-Regression verwendet, um eine einfache Erklärung mit nur wenigen relevanten Variablen zu erhalten.
  • 🌐 **LIME kann auf verschiedene Arten von Daten angewendet werden, wie im Video gezeigt wird, um Erklärungen für Bilder, Textdaten und andere zu erstellen.

Q & A

  • Was ist LIME und was bedeutet die Abkürzung?

    -LIME steht für 'Local Interpretable Model-agnostic Explanations'. Es ist eine Methode, um Black-Box-Algorithmen zu erklären, indem es lokale, interpretierbare Erklärungen erstellt.

  • Wozu dient die LIME-Methode?

    -LIME dient dazu, lokale Erklärungen für individuelle Vorhersagen von Black-Box-Modellen zu erzeugen, ohne auf die gesamte Komplexität des Modells eingehen zu müssen.

  • Warum ist es schwierig, Black-Box-Modelle zu erklären?

    -Black-Box-Modelle sind komplex und ihre Entscheidungsprozesse sind oft nicht linear, was es schwierig macht, eine einfache und verständliche Beziehung zwischen Eingabe und Vorhersage zu finden.

  • Wie funktioniert die Grundidee von LIME?

    -Die Grundidee von LIME besteht darin, auf eine kleine Umgebung des zu erklärenden Datenpunktes zu zoomen und dort eine einfache Erklärung zu erstellen, die in dieser lokalen Region Sinn ergibt.

  • Was ist eine 'lokale Approximation' in Bezug auf LIME?

    -Eine lokale Approximation ist ein einfaches Modell, das in der Nähe eines bestimmten Eingabedatenpunktes eine gute Annäherung an das komplexe Modell darstellt.

  • Wie wird die Nähe zu einem Datenpunkt in LIME definiert?

    -Die Nähe zu einem Datenpunkt wird in LIME durch eine Proximity-Funktion definiert, die als Abstandsmessung dient und oft mit einem Exponentialkern implementiert wird.

  • Was ist das Ziel der mathematischen Optimierungsprobleme, die in LIME verwendet werden?

    -Das Ziel ist es, ein einfaches Modell zu finden, das sowohl die komplexen Modelle in der Umgebung des Datenpunktes annähert als auch so einfach wie möglich bleibt.

  • Wie wird die Einfachheit des lokalen Modells in LIME gewährleistet?

    -Die Einfachheit wird durch Regularisierung erreicht, oft durch Verwendung von Lasso-Linear-Regression, um eine sparsame lineare Modelle zu erhalten, die viele Null-Gewichte haben.

  • Welche Art von Daten kann LIME erklären?

    -LIME kann fast jeden Eingabetyp erklären, wie Text, tabellarische Daten, Bilder oder sogar Graphen.

  • Welche Rolle spielen Fachexperten bei der Verwendung von LIME?

    -Fachexperten können die Erklärungen von LIME nutzen, um das Modell zu validieren und zu verstehen, ob es sinnvolle Vorhersagen trifft, basierend auf ihrem vorherigen Wissen über das Problem.

  • Wie wird die Genauigkeit der lokalen Erklärungen in LIME gewährleistet?

    -Die Genauigkeit wird durch das Minimieren der Verlustfunktion gewährleistet, die sowohl die Annäherung des komplexen Modells in der lokalen Umgebung als auch die Einfachheit des einfachen Modells berücksichtigt.

Outlines

00:00

🧠 Einführung in LIME

Dieser Absatz stellt das Konzept der Local Interpretable Model-agnostic Explanations (LIME) vor, eine Methode zur Erklärung von schwarzen Kastent-Algorithmen. LIME ermöglicht es, komplexe Modelle lokal zu approximieren, um eine einfache Erklärung für eine bestimmte Vorhersage zu schaffen. Im Gegensatz zu globalen Erklärungen, die das gesamte Modell erklären, konzentriert sich LIME sich auf die lokale Umgebung einer Vorhersage. Der Absatz führt das Motivationsbeispiel des Stroke-Datensatzes ein und stellt die Herausforderung dar, wie man eine Vorhersage für einen neuen Datenpunkt erklären kann, wenn das Modell eine komplexe, nicht-lineare Entscheidungsgrenze hat.

05:01

🔍 Funktionsweise von LIME

In diesem Absatz wird erläutert, wie LIME funktioniert. Es wird betont, dass LIME eine lineare Erklärung in der Nähe einer bestimmten Eingabe generiert, um eine lokale Approximation des komplexen Modells zu schaffen. Die Erklärung wird durch eine mathematische Optimierung erreicht, bei der zwei Verlustterme minimiert werden: Einer, der die Übereinstimmung zwischen dem komplexen Modell und der einfachen Erklärung in der Umgebung der Datenpunkte gewährleistet, und einer, der die Komplexität der Erklärung reduziert, indem die Anzahl der relevanten Variablen begrenzt wird. Der Absatz beschreibt auch, wie LIME neue Datenpunkte in der Nähe der Eingabe generiert und wie diese zur Anpassung einer einfachen linearen Regression verwendet werden.

10:01

💻 Anwendung von LIME

Der dritte Absatz beschreibt die praktische Anwendung von LIME mithilfe eines Beispiels. Es wird gezeigt, wie man einen Random Forest Classifier als schwarzes Modell verwendet und wie LIME lokal Erklärungen für Vorhersagen erstellt. Die Verwendung von LIME auf verschiedenen Datentypen wie Tabellendaten, Bildern und Text wird diskutiert. Der Absatz betont die Bedeutung von LIME zur Validierung von Modellen und zur Verbesserung der Akzeptanz von Vorhersagealgorithmen durch die Bereitstellung von Erklärungen. Es wird auch darauf hingewiesen, dass es wichtig ist, mehrere lokale Vorhersagen zu betrachten, um ein globales Verständnis des Modellverhaltens zu erhalten.

Mindmap

Keywords

💡LIME

LIME steht für 'Local Interpretable Model-agnostic Explanations' und ist eine Methode, die verwendet wird, um die Entscheidungen von künstlichen neuronalen Netzwerken und anderen komplexen künstlichen Intelligenz-Modellen zu erklären. Es ist ein lokaler Ansatz, der eine einfache Erklärung für eine bestimmte Vorhersage in der Nähe eines Datenpunktes generiert. Im Video wird LIME als populäre Methode für die Erklärung von 'Black Box'-Algorithmen vorgestellt, die verwendet werden kann, um die Vorhersage eines Modells für einen neuen Datenpunkt zu erklären.

💡Black Box Algorithmen

Ein 'Black Box'-Algorithmus ist ein Modell, dessen interne Funktionsweise und Entscheidungsprozesse für Menschen nicht transparent sind. Im Kontext des Videos wird ein 'Black Box'-Algorithmus verwendet, um auf komplexe Daten wie Alter und Körpermasseinsatz zu trainieren und Vorhersagen über Schlaganfälle zu treffen, ohne dass die spezifischen Entscheidungswege leicht nachzuvollziehen sind.

💡lokale Erklärung

Eine lokale Erklärung bezieht sich auf eine Erklärung, die nur für eine spezifische Vorhersage oder einen spezifischen Datenpunkt gilt. Im Video wird gezeigt, wie LIME eine lokale Erklärung für die Vorhersage eines Schlaganfalls erstellt, indem es sich auf die Umgebung des betreffenden Datenpunktes konzentriert und eine einfache lineare Erklärung in dieser Region findet.

💡lokale Approximation

Eine lokale Approximation ist ein Prozess, bei dem ein einfacheres Modell verwendet wird, um die Vorhersagen eines komplexen Modells in der Nähe eines bestimmten Datenpunktes zu approximieren. Im Video wird LIME verwendet, um eine lineare lokale Approximation zu erstellen, um die Vorhersage eines 'Black Box'-Algorithmus für einen neuen Datenpunkt zu erklären.

💡lokale Treffsicherheit

Lokale Treffsicherheit bezieht sich auf die Fähigkeit einer Erklärung, die Vorhersage eines Modells für einen spezifischen Datenpunkt korrekt zu reflektieren. Im Video wird betont, dass LIME Erklärungen erstellt, die lokal treu sind, aber möglicherweise nicht global sinnvoll sind, was darauf hinweist, dass sie sich auf die Umgebung des Datenpunktes konzentrieren, für den die Erklärung erstellt wurde.

💡komplexe Modelle

Komplexe Modelle sind künstliche neuronale Netzwerke oder andere künstliche Intelligenz-Modelle, die viele Ebenen oder eine große Anzahl von Parametern haben und daher schwierig zu interpretieren sind. Im Video wird ein komplexes Modell verwendet, um auf das Stroke-Dataset zu trainieren, und LIME wird angewendet, um die Entscheidungen dieses Modells zu erklären.

💡lokale Umgebung

Die lokale Umgebung bezieht sich auf die Datenpunkte, die in der Nähe eines bestimmten Datenpunktes liegen, auf den sich die Erklärung bezieht. Im Video wird die lokale Umgebung verwendet, um die Datenpunkte zu generieren, die für die lokale Approximation des Modells verwendet werden, indem Datenpunkte in der Nähe des Eingabedatenpunktes perturbiert werden.

💡Proximity Measure

Eine Nähenmessung ist ein Maß, das verwendet wird, um die Distanz oder die Ähnlichkeit zwischen Datenpunkten zu messen. Im Video wird eine Nähenmessung verwendet, um die Datenpunkte zu gewichten, die für die Erstellung der lokalen Erklärung generiert werden, wobei Datenpunkte, die näher am Eingabedatenpunkt liegen, stärker gewichtet werden.

💡lineare Regression

Lineare Regression ist eine einfache statistische Methode, die verwendet wird, um die Beziehung zwischen einer unabhängigen Variablen und einer abhängigen Variablen zu modellieren. Im Video wird eine lineare Regression als ein Beispiel für ein interpretierbares Modell verwendet, das in der Nähe eines Datenpunktes passt, um eine lokale Erklärung für die Vorhersage eines 'Black Box'-Algorithmus zu erstellen.

💡Sparsity

Sparsity bezieht sich auf die Eigenschaft eines Modells, bei dem viele der Koeffizienten Null oder sehr klein sind, was bedeutet, dass nur wenige Variablen für die Vorhersage relevant sind. Im Video wird Sparsity verwendet, um zu gewährleisten, dass die lokale Erklärung durch LIME einfach ist, indem die Anzahl der Variablen minimiert wird, die in der linearen Regression verwendet werden.

Highlights

LIME (Local Interpretable Model-agnostic Explanations) ist eine Methode zur Erklärung von schwarzen Kastent-Algorithmen.

LIME ist model-agnostisch und kann für jeden maschinellen Lernmodell verwendet werden.

LIME konzentriert sich auf die Erklärung von individuellen Vorhersagen in der Nähe eines Datenpunktes.

Die Vorhersage eines komplexen Modells kann hochgradig nicht-linear sein, was eine einfache Erklärung schwierig macht.

LIME erzeugt eine einfache Erklärung, indem es in der Nähe des Datenpunktes eine lineare, interpretierbare Modellauswahl durchführt.

LIME verwendet eine lokale Approximation des komplexen Modells, um eine valide Erklärung für die Vorhersage zu geben.

Die Erklärungen von LIME sind lokal treu, aber sie müssen nicht global sinnvoll sein.

LIME kann für fast alle Arten von Eingaben wie Text, tabellarische Daten, Bilder oder sogar Graphen verwendet werden.

LIME kann helfen, das Vertrauen in ein Modell aufzubauen, indem es überprüft, ob die Erklärungen sinnvoll sind.

Die Bereitstellung von Erklärungen durch LIME kann die Akzeptanz eines prädiktiven Algorithmus erhöhen.

LIME verwendet eine mathematische Optimierungsproblem, um eine lokale Approximation des komplexen Modells zu erstellen.

Die Optimierungsfunktion von LIME minimiert die Komplexität des einfachen Ersatzmodells, um einfache Erklärungen zu gewährleisten.

LIME generiert neue Datenpunkte in der Nähe des Eingabedatenpunktes, um die lokale Approximation zu erstellen.

Die Verlustfunktion von LIME verwendet eine Exponential-Kernel als Abstandsmetrik, um die lokale Treue zu gewährleisten.

LIME verwendet sparsche lineare Modelle, um die Anzahl der relevanten Variablen zu reduzieren und die Erklärungen einfach zu halten.

LIME kann auf einem Datensatz angewendet werden, um lokale Erklärungen für Vorhersagen eines schwarzen Kastench-Modells zu erhalten.

LIME kann auch auf anderen Datentypen wie Bildern oder Textdaten angewendet werden, um lokale Erklärungen zu erhalten.

Es wird empfohlen, mehrere lokale Vorhersagen von LIME zu betrachten, um ein globales Verständnis des Modellverhaltens zu erhalten.

Transcripts

play00:03

hey guys

play00:04

welcome back to this explainable ai

play00:06

series today we want to have a closer

play00:08

look at one of the most popular methods

play00:10

for explaining black box algorithms

play00:13

which is lime lime stands for local

play00:16

interpretable model agnostic

play00:18

explanations

play00:19

and as the name implies it's model

play00:21

agnostic therefore it can be used for

play00:23

any machine learning model

play00:24

let's first talk about the idea and

play00:26

motivation behind this approach

play00:28

think of the stroke data set we've used

play00:30

in the last video

play00:31

imagine we train a black box algorithm

play00:34

on two features of this data set

play00:36

this could be things like age or body

play00:39

mass index

play00:40

after the training the decision boundary

play00:42

of our complex model could look like

play00:44

this

play00:45

so that's just an example for a new data

play00:48

point

play00:48

if it falls into the blue area we

play00:50

predict no stroke

play00:52

otherwise we predict stroke so the

play00:54

prediction we make

play00:55

is highly non-linear or in other terms

play00:58

there is no easy to explain

play01:00

relationship in how we perform a

play01:02

prediction

play01:03

the model just learned some complex

play01:05

patterns as a combination of those two

play01:07

features

play01:08

if we make a prediction for john now for

play01:11

instance

play01:12

stroke how could we explain to him why

play01:15

our model outputs

play01:16

stroke we cannot easily summarize the

play01:19

whole decision boundary into one

play01:21

explanation

play01:22

the basic idea of lime is that we just

play01:24

zoom into the local area of the

play01:26

individual prediction

play01:28

there we can easily create a simple

play01:30

explanation that makes sense in that

play01:31

local region

play01:33

this way we don't have to worry about

play01:34

the rest of the model

play01:36

and still get a valid explanation why

play01:38

that prediction was made for instance in

play01:40

this example we could say that the

play01:42

prediction was made because the value of

play01:44

feature 2

play01:45

was small enough to fall on the left

play01:48

side of this dashed line

play01:50

we can also say something about the

play01:52

importance of our variables

play01:54

certainly feature 2 here mainly

play01:56

determines our output class

play01:58

and changes in feature 1 almost have no

play02:00

impact

play02:02

if you've watched the second video of

play02:03

the series about by design interpretable

play02:06

models

play02:06

you probably recall how we can interpret

play02:09

linear regression or

play02:10

simple decision trees to get such kind

play02:13

of explanations

play02:14

lime simply fits a linear interpretable

play02:16

model

play02:17

in that local area which is often also

play02:19

called surrogate

play02:20

it's basically a local approximation of

play02:23

our complex model

play02:24

in this local area so that's the basic

play02:27

idea and now let's have a look at this

play02:29

in more detail lime was presented in the

play02:31

paper on the right

play02:32

and aims to explain any black box model

play02:34

by creating such a local approximation

play02:37

the complex models are complete black

play02:40

boxes and the internals are hidden for

play02:42

lime so it's just based on the inputs

play02:45

and outputs of a model

play02:46

it works on almost any input such as

play02:49

text

play02:50

tabular data images or even graphs

play02:53

usually the domain experts in a certain

play02:55

field let's say medicine

play02:57

have some prior knowledge about the

play02:59

problem for example sports has a

play03:01

positive impact on the overall health

play03:04

if the lime explanation tells us that

play03:06

sports increases the probability of a

play03:08

stroke there's most likely something

play03:10

wrong in our developed model

play03:12

so that helps to build trust and we can

play03:14

assess whether it makes sense or not

play03:16

in the paper they also state that

play03:18

providing explanations

play03:19

improves the acceptance of a predictive

play03:22

algorithm

play03:23

for lyme the only requirement is that

play03:25

the explanations are locally faithful

play03:28

but they might not make sense globally

play03:30

so we just focus on that local area

play03:32

around our prediction

play03:34

now let's have a look at the

play03:35

mathematical optimization problem used

play03:37

in line

play03:38

the idea behind it is actually quite

play03:40

intuitive as already mentioned we want

play03:42

to create a local approximation of our

play03:45

complex model

play03:46

for a specific input for instance we

play03:48

know the properties of john

play03:50

in a tabular format so that would be our

play03:52

input data point x

play03:54

in this optimization formula from the

play03:56

line paper

play03:57

the complex model is denoted with f and

play04:00

the simple model so the local model is

play04:02

denoted with

play04:03

g this simple model small g

play04:07

comes from a set of interpretable models

play04:09

which is denoted with a capital g

play04:11

here capital g is a family of linear

play04:15

models such as linear regression and all

play04:17

its variants

play04:18

in the line paper this family is set to

play04:21

sparse linear models

play04:22

we will further talk about this in a

play04:24

second now this first loss term in our

play04:27

optimization function

play04:28

simply means that we look for an

play04:30

approximation of the complex model f

play04:32

by the simple model g in the

play04:34

neighborhood of our data point x

play04:37

in other terms we want to get a good

play04:39

approximation in that local

play04:40

neighborhoods the third argument

play04:43

pi here defines the local neighborhoods

play04:46

of that data point

play04:47

and is some sort of proximity measure we

play04:50

will see more details in a minute

play04:52

the second loss term is used to

play04:54

regularize the complexity

play04:56

of our simple surrogate model for linear

play04:58

regression for instance a desirable

play05:00

condition could be to have many

play05:02

zero-weighted input features so

play05:04

basically ignoring most of the features

play05:06

and just including a few this makes our

play05:09

explanations

play05:10

more simple for decision tree it would

play05:12

be nice to have a relatively small depth

play05:14

that stays comprehensible for humans

play05:18

so overall this omega is a complexity

play05:20

measure

play05:21

and as this optimization problem is a

play05:23

minimization problem

play05:25

we want to minimize the complexity in

play05:28

summary this loss function says that we

play05:30

look for a simple model g

play05:32

so this is the argument in the arc min

play05:34

that minimizes those two loss terms so

play05:37

it should

play05:37

approximate the complex model in that

play05:39

local area and additionally stay as

play05:41

simple as possible

play05:43

now how is this first loss term

play05:45

calculated so on the right you see the

play05:47

decision boundary of our complex model f

play05:50

again zoomed into that local area of our

play05:52

prediction for john

play05:54

in the first step we simply generate

play05:56

some new data points in the neighborhood

play05:58

of our input data point

play06:01

more specifically we randomly generate

play06:03

data points

play06:04

everywhere but as we will see in a

play06:06

second they will be weighted according

play06:09

to the distance to our input data point

play06:11

as we are just interested

play06:12

in the local area around our input these

play06:15

data points are generated by

play06:17

perturbations

play06:18

so for instance we can slightly increase

play06:20

the h decrease the body mass index

play06:22

and so on this can be achieved by

play06:24

sampling from a normal distribution

play06:27

with the mean and standard deviation for

play06:28

each feature

play06:30

then we get the prediction for these

play06:32

data points using our complex model f

play06:35

so here all the points in the blue area

play06:37

would be predicted as

play06:39

no stroke and the ones on the other side

play06:41

as stroke

play06:42

what we end up with is a new data set we

play06:44

can use to fit a classifier

play06:46

we have the labels which come from the

play06:48

predictions of the complex model f

play06:51

and we have all the feature values which

play06:53

are simply the sample new data points

play06:56

so we minimize the first loss term by

play06:58

simply getting the highest accuracy

play07:00

on that new data set using a simple

play07:03

linear model

play07:04

for a linear regression for instance we

play07:06

minimize the sum of square distances

play07:09

between the predictions and the ground

play07:11

truth in the line paper they use this

play07:13

loss function for optimizing a linear

play07:15

model

play07:16

it's basically the sum of squared

play07:17

distances between the label

play07:19

which comes from the complex model and

play07:21

the prediction of the simple model g

play07:24

additionally the proximity pi is added

play07:27

to weight the loss

play07:28

according to how close a data point is

play07:30

for instance classifying this black data

play07:33

point wrong

play07:34

is not relevant because it falls out of

play07:36

the local neighborhoods

play07:38

in the paper they use an exponential

play07:39

kernel as distance metric

play07:41

so we can think of this like a heat map

play07:44

the points that are

play07:45

close to our input data points are

play07:47

weighteds the most

play07:48

that's how we ensure that the model is

play07:50

locally faithful

play07:52

okay so the first part of that loss

play07:54

function should make sense now

play07:56

what about the omega at the end we said

play07:59

we use it to make sure that our model

play08:01

stays simple

play08:02

in lime a sparse linear model is used

play08:05

the advantage of this

play08:06

is that we additionally take care of the

play08:08

second loss term

play08:09

because sparse linear models aim to

play08:11

produce as many zero weights as possible

play08:14

in practice this can be achieved by

play08:15

using a regularization technique

play08:17

such as done for lasso linear regression

play08:20

for instance

play08:22

this way we ensure to get a simple

play08:23

explanation with only a few relevant

play08:26

variables so that's how we also take

play08:28

care of the second loss term

play08:29

now it's time for some code let's have a

play08:32

look at how we can apply

play08:33

lime on our data set okay so here we are

play08:36

back in vs code first we import a couple

play08:38

of things that data

play08:40

loader i've shown in the last video

play08:42

which simply fetches our data

play08:44

which is a csv file in a tabular format

play08:47

and then uh the random forest classifier

play08:49

which will serve as our black box model

play08:52

in this case

play08:52

as it's an ensemble model that cannot be

play08:55

easily interpreted

play08:56

then we import some metrics like the f1

play08:58

score and the accuracy score

play09:00

as we have an imbalanced data set it

play09:02

makes sense to also look at recall and

play09:04

precision

play09:05

then we import line tabular which is

play09:08

lime for tabular data

play09:10

and it comes from microsoft's interpret

play09:12

library

play09:14

and as you see it's for black box

play09:16

algorithms

play09:17

and finally we import the show function

play09:19

which helps us to create this

play09:21

interactive plot

play09:22

so in the second cell we load the data

play09:25

set using this load dataset function

play09:27

which simply gets the data as csv

play09:30

from pandas and then we pre-process it

play09:34

using the preprocess function here we do

play09:37

some

play09:37

imputations and one hot encodings and

play09:40

after that we simply split the data set

play09:42

into

play09:43

20 test data and 80 train data

play09:46

and then we do some over sampling to

play09:48

ensure that our minority class gets more

play09:51

importance in our predictions

play09:53

so let's run those first two cells

play09:57

it's opening our jupiter notebook and

play10:00

now what we do

play10:01

is we create this random forest

play10:03

classifier

play10:05

and fit it using our data

play10:09

and as you can see the accuracy is much

play10:11

better than the previous models we had

play10:14

and also our f1 score is slightly

play10:16

increased

play10:17

it's still not good as it's a relatively

play10:20

complex

play10:21

imbalanced data set but accuracy is

play10:24

pretty good so

play10:25

we can continue with that and now what

play10:28

we do

play10:28

is we use this line tabular class and

play10:31

use

play10:32

our random forest classifier or more

play10:34

specifically the prediction

play10:35

probabilities and pass it our data sets

play10:43

and what we can do now is we can pass

play10:45

the

play10:46

first or the last 20 instances of our

play10:48

data set

play10:49

to make lime explain them locally

play10:53

and what that does is simply creating

play10:55

those local explanations we've just seen

play10:57

that means we fit a local model in the

play11:00

area around each of those 20 data points

play11:03

so let's run this and this will take

play11:05

some time as we have to fit an entirely

play11:08

new model

play11:09

and also sample a data set for each of

play11:11

those

play11:12

20 data points okay so now it's done

play11:16

and after calling this show function on

play11:18

our local explanations

play11:20

we get this interactive graph which

play11:22

comes from this interpret library

play11:25

so we've trained our random forest

play11:26

classifier with 94

play11:28

accuracy but can we be sure that the

play11:31

model really uses the right features and

play11:34

works as intended

play11:35

and to better understand that we can now

play11:37

have a look at individual predictions

play11:39

and here we see we have for example

play11:41

actual value of 0 which means no stroke

play11:44

and we have predicted 0.01 as prediction

play11:47

probability

play11:48

so that's also pretty close to zero and

play11:51

the reason for that is

play11:52

so these are the features or the feature

play11:54

values used by our model

play11:56

and the hs has a strongly negative

play11:59

impact because the age is relatively low

play12:01

for a stroke prediction and that's why

play12:04

the prediction is shifted

play12:05

towards no stroke also that the person

play12:08

has no hypertension

play12:10

no heart disease and so on these are

play12:13

reasons

play12:13

why the model says this person is not

play12:15

getting a stroke

play12:17

if we have a look at another prediction

play12:19

here which is also

play12:21

predicting no stroke we see that the h

play12:23

is 22 here so relatively young

play12:26

and that's why the h has a even stronger

play12:29

impact

play12:29

for this individual prediction so as you

play12:32

can see

play12:33

lime can also be used on any black box

play12:36

model

play12:36

to get those kind of explanations we've

play12:39

also seen in a previous video

play12:41

so we've seen how we can use lime to

play12:43

create helpful local explanations to

play12:45

validate our black box model

play12:47

as mentioned before lime can also be

play12:49

applied on other data inputs here's an

play12:51

example for images as you can see

play12:54

depending on the prediction

play12:55

we get different areas in our input

play12:57

which are marked

play12:59

as most important for the prediction

play13:01

here's another example for

play13:03

text data this example shows how helpful

play13:06

lime can be

play13:07

for validating a model on the left we

play13:10

can see that the output class was

play13:12

atheism

play13:12

with 58 probability and in the middle

play13:16

we can see hosting hosts nntp

play13:19

and edu led to a prediction for atheism

play13:23

however with our domain knowledge we

play13:25

know that those words have nothing to do

play13:27

with the religion and that's why we can

play13:30

say there's something going

play13:31

wrong in this model in the paper they

play13:33

also suggest to always look at several

play13:36

local predictions

play13:37

to get a global understanding of what

play13:39

our model is doing

play13:40

so that's it for today i try to keep it

play13:43

short if there's anything else you are

play13:45

interested in

play13:45

just let me know in the comments see you

play13:47

in the next video where we will have a

play13:49

look at another popular method called

play13:51

shep thanks for watching and have a

play13:53

great day

Rate This

5.0 / 5 (0 votes)

Related Tags
LIMEMachine LearningDatenanalyseAlgorithmenTransparenzModellvalidierungKünstliche IntelligenzDateninterpretationBlack BoxErklärbare AI
Do you need a summary in English?