【发布时间】:2014-12-11 04:29:10
【问题描述】:
我想使用派对库中的 cforest 函数来衡量特征的重要性。
我的输出变量在 0 类中有 2000 个样本,在 1 类中有 100 个样本。
我认为避免由于类不平衡而产生偏差的一个好方法是使用子样本训练森林中的每棵树,使类 1 的元素数与类 0 中的元素数相同。
有没有办法做到这一点?我正在考虑像n_samples = c(20, 20)这样的选项
编辑: 代码示例
> iris.cf <- cforest(Species ~ ., data = iris,
+ control = cforest_unbiased(mtry = 2)) #<--- Here I would like to train the forest using a balanced subsample of the data
> varimp(object = iris.cf)
Sepal.Length Sepal.Width Petal.Length Petal.Width
0.048981818 0.002254545 0.305818182 0.271163636
>
编辑: 也许我的问题还不够清楚。 随机森林是一组决策树。通常,决策树仅使用数据的随机子样本构建。我希望使用的子样本在 1 类和 0 类中具有相同数量的元素。
编辑: 我正在寻找的功能肯定在 randomForest 包中可用
sampsize
Size(s) of sample to draw. For classification, if sampsize is a vector of the length the number of strata, then sampling is stratified by strata, and the elements of sampsize indicate the numbers to be drawn from the strata.
派对包我也需要同样的东西。有没有办法得到它?
【问题讨论】:
标签: r random-forest party