Example with random forest model

Anna Kozak

2020-02-27

Example with random forest regression model

In this vignette we present measure for random forest regression model.

1 Dataset

We work on Apartments dataset from DALEX package.

#>   m2.price construction.year surface floor no.rooms    district
#> 1     5897              1953      25     3        1 Srodmiescie
#> 2     1818              1992     143     9        5     Bielany
#> 3     3643              1937      56     1        2       Praga
#> 4     3517              1995      93     7        3      Ochota
#> 5     3013              1992     144     6        5     Mokotow
#> 6     5795              1926      61     6        2 Srodmiescie

2 Random forest regression model

Now, we define a random forest regression model and use explain from DALEX.

3 New observation

We need to specify an observation. Let consider a new apartment with following attributes. Moreover, we calculate predict value for this new observation.

4 Calculate Ceteris Paribus profiles

Let see the Ceteris Paribus Plots calculated with ceteris_paribus() function.

5 Calculate measure of local variable importance

Now, we calculated a measure of local variable importance via oscillation based on Ceteris Paribus plot. We use variant with all parameters equals to TRUE.

For the new observation the most important variable is surface, then floor, construction.year and no.rooms.