1

我是 R 新手,正在做作业。我们需要在给定的数据集上为随机森林和特征交互做一个例子。当我运行代码时,我得到了绘图但没有任何数据。请帮助我,因为我从未在 R 中编程,我需要这样做。谢谢!

我已经尝试只使用没有 N/A 值的列

  X <- student_data_train %>%
    select(-GradePASS) %>%
    as.data.frame()

  predictor <- Predictor$new(rf_model, data = X, y = student_data_train$GradePASS)
  str(predictor)

  install.packages("devtools")
  library(devtools)
  interact <- Interaction$new(predictor, feature = "selfassesm")
  interact$plot()
  interact$results %>%
    ggplot(aes(x = reorder(.feature, .interaction), y = .interaction, fill = .class)) +
    facet_wrap(~ .class, ncol = 2) +
    geom_bar(stat = "identity", alpha = 0.8) +
    scale_fill_tableau() +
    coord_flip() +
    guides(fill = FALSE)
4

0 回答 0