DALEX: which variables are really important? Ask your black box model!

Third post from the short series about black-box explainers implemented in the DALEX package. Learn more about DALEX at SER (Warsaw, April 2018), eRum (Budapest, May 2018), WhyR (Wroclaw, June 2018) or UseR (Brisbane, July 2018).

Two weeks ago I wrote about single variable conditional responses and last week I wrote about decompositions of a single prediction.

Sometimes we would like to know the general structure of a model, or at least know which variables are the most influential. There is a lot of different approaches to this problem proposed in literature. A nice, simple, and model agnostic approach is described in this article (Fisher, Rudin, and Dominici 2018). To see how important is variable X let’s permute it’s values and measure the drop in model accuracy.
This procedure is implemented in the DALEX package in the variable_dropout() function. There are some tweaks (for large datasets you do not need to permute all rows while for small datasets you could consider some oversampling) but the idea is the same.

In the figure below you will find variable importances for three models created with the HR dataset. It is easy to spot that the randomForest model results in the best model and satisfaction_level is the most important variable in all three models.

plot.variable_dropout_explainer-19

There are two things that I like in this explainer.

1) Variable effects for a single model are interesting, but ability to compare effects for many modes is even more interesting. In the DALEX you can simply contrast/compare explainers across different models.

2) There is no reason to start variable importance plots in the point 0, since the initial model performance is different for different plots. It is much more informative to present both the initial model performance and drop in the performance resulting from the dropout of a variable.

If you want to learn more about DALEX package and variable importances consult following vignette or the DALEX website.

DALEX_variable_dropout

Rozstrzygnięcie konkursu Data Science Masters na najlepszą pracę z DS i ML

Screen Shot 2018-03-14 at 9.20.11 AM
Dzisiaj dzień liczby Pi. Dobry dzień na rozstrzygnięcie PIerwszej edycji konkursu Data Science Masters na najlepsza pracę magisterską.

Ze zgłoszonych 72 prac trzeba było wybrać 3, które otrzymają nagrodę. Tematyka tych prac była bardzo różna (chmura słów po prawej została wygenerowana z tytułów i abstraktów). Prace zgłaszane były z całej Polski (statystyki dotyczące uczelni są poniżej). Na gali będzie można zapoznać się z procedurą konkursową oraz z nagrodzonymi pracami. Autorzy nagrodzonych prac zostali poproszeni o kilkunasto-minutowe prezentacje.

W imieniu komisji oraz organizatorów (MiNI PW i Nethone) serdecznie zapraszam dzisiaj do sali 107 na godzinę 16:15. Po gali, przy poczęstunku, będzie można porozmawiać z nagrodzonymi. Więcej informacji tutaj.

How fractals helped my students to master package development in R

Last semester I taught an R programming at MIMUW. My lectures are project oriented, the second project was related to package development. The idea was straightforward: each team of students shall create a package that produces IFS fractals (based on iterated function systems). Each package shall have two generic functions: create() and plot(), documentation and vignette. Fractals shall be implemented with the use of S3 or S4 classes.

I have students with different backgrounds. Mostly statistics, but some are from physics, psychology or biology. I was a bit unsure how they will deal with concepts like iterated contractions.
After all results exceeded my expectations.

Guess what is happening with students engagement when their packages start producing nice plots. Their need/hunger for more leads to beautiful things.

This team got interested in nonlinear transformations. They manage to create Apollonian Gasket generator and much more. See their vignette and package here.

Screen Shot 2018-03-09 at 7.31.24 PM

This team got interested in probabilistic mixtures of two fractals. They developed a Shiny app that mixes two sets of contractions with given mixture proportions. Here is a mixture of Sierpinski gasket and a tree. Find out their vignette here.

Screen Shot 2018-03-09 at 7.29.58 PM

This team got interested in random fractals. They developed fractal generator that draws parameters of each contraction. In result they get beautiful random shapes like these. Here is their vignette.

Screen Shot 2018-03-09 at 7.37.42 PMScreen Shot 2018-03-09 at 7.37.31 PMScreen Shot 2018-03-09 at 7.37.26 PM

And these two teams got interested in different ways of fractal colouring. Vignettes of Team 1 and Team 2

Screen Shot 2018-03-09 at 7.40.15 PMScreen Shot 2018-03-09 at 7.36.01 PMScreen Shot 2018-03-09 at 7.31.05 PM

After all it turns out that fractals are very addictive!
Use it with care 😉

BetaBit: Tato, kiedy ty mi to wreszcie wytłumaczysz….

Konigsberg_riverCzasem, gdy rozmawiam o edukacji matematycznej dla dzieci, temat schodzi na zagadnienia typu: w jakie słodkie opakowanie ubrać tę gorzką pigułkę wiedzy, aby dziecko chciało ją połknąć. Że to niby tyle różnych cukierków dookoła, tu gra, tam facebook, trzeba z takimi gigantami rywalizować o uwagę dziecka.

Ale czy tak faktycznie jest? Mój syn mnie kiedyś zabił pytaniem ,,Tato, kiedy ty mi wreszcie wytłumaczysz co to jest DNA”? Zacząłem się zastanawiać, jak wyglądałaby interakcja pomiędzy uczniem a nauczycielem, gdyby uczeń robił co tylko może by wyciągnąć od nauczyciela wiedzę, a nauczyciel co tylko może by żadnej wiedzy nie przekazać. Do jakich pytań posunąłby się uczeń aby wyrwać nauczycielowi skrawki tajemnicy?

Skracając te przemyślenia i przechodząc do pointy.
Napisałem krótkie opowiadanko o takim chłopcu co bardzo chciał wiedzieć jak rozwiązać zagadkę z mostami w Królewcu.
Znajdziecie je tutaj.