ModelOriented / randomForestExplainer

A set of tools to understand what is happening inside a Random Forest
https://ModelOriented.github.io/randomForestExplainer/
230 stars 37 forks source link

Add ability to change x and y labels plot_predict_interaction #6

Closed OliverFishCode closed 5 years ago

OliverFishCode commented 5 years ago

It would be nice to be able to change x and y labels like you can with the title

Yue-Jiang commented 5 years ago

I'm not sure adding it as an option to the function is a general use case. However since plot_predict_interaction returns a ggplot object, you can update the labels on top of it:

library(randomForestExplainer)
library(randomForest)
library(ggplot2)
data(Boston, package = "MASS")
Boston$chas <- as.logical(Boston$chas)
set.seed(2017)
forest <- randomForest(medv ~ ., data = Boston, localImp = TRUE)
p <- plot_predict_interaction(forest, Boston, "rm", "lstat")
p + labs("my custom x lab", "my custom y lab")

image

Yue-Jiang commented 5 years ago

Closing because an example has been provided above to modify labels post figure generation.