DALEX: how would you explain this prediction?

Last week I wrote about single variable explainers implemented in the DALEX package. They are useful to plot relation between a model output and a single variable.

But sometimes we are more focused on a single model prediction. If our model predicts possible drug response for a patient, we really need to know which factors drive the model prediction for a particular patient. For linear models it is relatively easy as the structure of the model is additive. In 2017 we have developed breakDown package for lm/glm models.

But how to explain/decompose/approximate predictions for any black box model?
There are several approaches. The (probably) most known is LIME with great examples for image and text data. There is an R port lime developed by Thomas Pedersen. In collaboration with Mateusz Staniak we developed live package, similar approach, easy to use with models created by mlr package.
The other technique that can be used here are Shapley values which use attribution theory/game theory to attribute effects of different variables for a single prediction.

Recently we have developed a yet another approach (paper under preparation, implemented in the breakDown version 0.4) that works in a model agnostic way (here you can check how to use it for caret models). You can play with it via the single_prediction() function in the DALEX package.
Such decomposition is useful for many reasons mentioned in papers listed above (deeper understanding, validation, trust, etc).
And, what is really extra about the DALEX package, you can compare contributions of different models on the same scale.

Let’s train three models (glm / gradient boosting model and random forest model) to predict quality of wine. These models are very different in structure. In the figure below, for a single wine, we compare predictions calculated by these models. For this single wine, for all models the most influential variable is the alcohol concentration as the wine has much higher concentration than average. Then pH and sulphates take second and third positions in all three models. Looks like models have some agreement even if they structure is very different.

plot.single_prediction_explainer-19

If you want to learn more about DALEX package and decompositions for model predictions please consult following cheatsheet or the DALEX website.

If you want to learn more about explainers in general, join our DALEX Invasion!
Find our DALEX workshops at SER (Warsaw, April 2018), ERUM (Budapest, May 2018), WhyR (Wroclaw, June 2018) or UseR (Brisbane, July 2018).

DALEX_single_prediction

Czy transakcyjne podejście do ucznia jest dobre w Data Science?

singapore-13546711157mA

Sporo czasu spędziłem ostatnio w National Institute of Education (NIE) in Singapore gdzie kształci się nauczycieli na każdym poziomie nauczania. Gdy patrzeć na wyniki Singapuru przez pryzmat badania PISA, to trudno uwierzyć, że żyją tu ludzie a nie roboty. Wyniki badania z 2015 roku plasują Singapur na 1 miejscu w praktycznie każdym kryterium (czytanie, matematyka, przyroda) i to z taką przewagą, że od drugiego miejsca dzieli ich przepaść.

Poruszając się po tym mieście-państwie widać w każdym miejscu olbrzymi nacisk położony na edukację, od ogrodu botanicznego (z masą edukacyjnych elementów), przez telewizję (z długimi programami na tematy naukowe i ekonomiczne) po metro.
Singapur ma też bardzo wysoki współczynniki nierówności Giniego, łatwo wyobrazić sobie prosty mechanizm w którym nacisk na edukacje wynika z chęci pozyskania lepszej pracy, wyższych zarobków itp.

W rozmowach z ludźmi z NIE ciekawiło mnie w jaki sposób teraz starają się kształtować zasady nauczania, co traktują za największe wyzwanie.
I tutaj ciekawa historia. Część z nich narzeka na bardzo transakcyjne podejście uczniów do edukacji. Podejście w którym za określony wysiłek czeka określona nagroda. Ale nie ma czasu na zwykłą ciekawość, zerkanie w bok, schodzenie ze szlaku. W artykułach o wysokich wynikach z PISA pojawia się pytanie: a gdzie innowacje?

Jak ta historia ma się do tytułowego kształcenia w Data Science? Hype wokół Data Science spowodował, że wiele osób traktuje ten zawód jako prosty sposób znaczącego podbicia sobie pensji po opanowaniu kilku konkretnych technik. Skupiając się na słówku Data zamiast na Science.

Tymczasem w dużej części do innowacji prowadzą nowe, pomysłowe zastosowania danych, a nie bezmyślne stosowania maszynek do młócenia danych. Aby znaleźć pomysłowe zastosowanie trzeba myśleć kreatywnie, ryzykować, schodzić ze szlaku. Próbować, upadać i próbować dalej aż się uda.

Hipoteza: programy studiów nie są na to gotowe. Często zaliczanie oparte jest o punkty, które można uzyskać za różne, niewielkie, bezpieczne zadania. Im bardziej pynkty są za bardzo konkretną aktywność, tym bardziej mamy transakcyjne/zamknięte podejście do nauczania.
Zamiast szukać smakołyków w danych, studenci mogą czuć pokusę by szukać punktów potrzebny do zaliczenia.
Nie jest to zreszta wina studentów, ponieważ zazwyczaj programy nauczania i kryteria określają nauczyciele akademiccy. Punkty wydają się być sprawiedliwym rozwiązaniem.
Moim zdaniem takie podejście jest jednak szkodliwe w tej mistycznej dyscyplinie jaką jest Data Science.
Jak nie transakcje to transformacje. Przedmiot (taki jak warsztaty badawcze) powinien zmieniać uczestnika (a uczestnikiem przedmiotu jest i uczeń i nauczyciel), wystawiać go poza strefę komfortu, generować nowe doświadczenia i rozwijać ciekawość do eksperymentowania.

DALEX: understand a black box model – conditional responses for a single variable

Black-box models, like random forest model or gradient boosting model, are commonly used in predictive modelling due to their elasticity and high accuracy. The problem is, that it is hard to understand how a single variable affects model predictions.

As a remedy one can use excellent tools like pdp package (Brandon Greenwell, pdp: An R Package for Constructing Partial Dependence Plots, The R Journal 9(2017)) or ALEPlot package (Apley, Dan. Visualizing the Effects of Predictor Variables in Black Box Supervised Learning Models (2016)).
OR
Now one can use the DALEX package to not only plot a conditional model response but also superimpose responses from different models to better understand differences between models.

Screen Shot 2018-02-19 at 12.27.58 AM

Consult the following vignette to learn more about the DALEX package and explainers for a single variable.

DALEX_single_variable

OR
if you want to learn more about explainers, join our DALEX Invasion!
Find our DALEX workshops at SER (Warsaw, April 2018), ERUM (Budapest, May 2018), WhyR (Wroclaw, June 2018) or UseR (Brisbane, July 2018).