如何修改通过将 ggplot 应用于使用 ranger 算法构建的插入符号对象生成的默认绘图图例?例如,假设我希望图例标题为“Splitting algo”而不是默认的“Splitting Rule”。
library(caret)
trainIndex <- createDataPartition(iris$Species, p = 0.80, list = FALSE)
train <- iris[ trainIndex,]
test <- iris[-trainIndex,]
rfs <- train(Species ~ ., data = train, trControl = trainControl(method = "cv", number = 10), method = "ranger", tuneGrid = expand.grid(mtry = seq(1, 3, 1), splitrule = c("gini", "extratrees"), min.node.size = 1))
ggplot(rfs) +
xlab("Number of parameters") +
ylab("Accuracy") +
theme(legend.title = "Splitting algo")