【问题标题】:Bivariate partial dependence with randomForest in RR中随机森林的二元部分依赖
【发布时间】:2016-12-30 07:25:16
【问题描述】:

我有一个数据集,其中包含一个二进制因变量和多个预测变量,包括参与者。我正在尝试检查不同预测变量对不同参与者的特殊影响。为了做到这一点,我试图查看参与者 id 和其他预测变量之间的交互对因变量的影响。我在 R 中使用 randomForest。我可以成功拟合森林,并且可以为各个变量生成部分依赖图。然而,我需要的是成对变量的部分依赖图 - 参与者 + 其他人。这可能吗?

供参考,我的代码:

data_sample<-data_raw[sample(1:nrow(data_raw),500,replace=F),];
test_rf<-randomForest(perceptually.rhotic~vowel+speaker+modified_clip_start+function_word+year_of_birth+gender+fathers_job_type+prepausal,data=data_sample,ntree=500,mtry=3);
partialPlot(test_rf,pred.dat=data_sample,x.var="speaker");

??? partialPlot(test_rf,pred.dat=data_sample,x.var=c("speaker","vowel"));

非常感谢任何人提供的任何建议!

【问题讨论】:

    标签: r statistics random-forest


    【解决方案1】:

    plotmo R 包将为“任何”模型绘制所有变量和变量对(双变量依赖)的部分依赖关系。例如:

    library(randomForest)
    data(trees)
    mod <- randomForest(Volume~., data=trees)
    library(plotmo)
    plotmo(mod, pmethod="partdep") # plot partial dependencies
    

    这给了

    您可以使用 plotmo 的 all1all2degree1degree2 参数准确指定绘制哪些变量和变量对。其他示例位于vignette for the plotmo package

    【讨论】:

      猜你喜欢
      • 2015-12-03
      • 1970-01-01
      • 2016-09-30
      • 1970-01-01
      • 2013-01-28
      • 2019-06-28
      • 2019-02-01
      • 2019-05-04
      • 1970-01-01
      相关资源
      最近更新 更多