Могу ли я удалить часть диапазона из графика plot_predict_interactions? - PullRequest
0 голосов
/ 08 мая 2020

Возможно ли не отображать часть цветной области на графике, полученной в результате plot_predict_interactions? На графиках показаны диапазоны (цвета), которые технически выходят за пределы диапазона набора данных, что сбивает с толку. Рассмотрим примеры ниже.

library(randomForest)
library(randomForestExplainer)

#Create arbitrary data frame
set.seed(123)
df <- data.frame(y=as.factor(c(rbinom(50,1,0.9), rbinom(50,1,0.2))),
                 x1=rlnorm(100), x2=rlnorm(100,2))

#Create simple random forest model (no weights)
res <- randomForest(y~x1+x2, data=df)

#Plot the interaction
plot_predict_interaction(res, df, "x1", "x2", grid = 50)

#Which data in the dataset are higher than x1 >7,5 and x2 >40? Answer: none!
df[df$x1 > 7.5 & df$x2 > 40,]
#I do not want to reduce the xlim and ylim of the plot just not display colours
#outside the range of the data.

Пример графика, не отображаемого за пределами диапазонов, можно найти на рисунке 4 (https://bgreenwell.github.io/pdp/articles/pdp-computation.html)

Спасибо за усилие

...