randomforest::randomforest()
的帮助页面显示:
"classwt - Priors of the classes. Need not add up to one. Ignored for regression."
当您有大量不平衡数据时,可以设置classwt
参数来帮助,即。类(class)的先验差异很大?
在具有 3 个类别且先验向量等于 (p1,p2,p3) 的数据集上训练模型时,应如何设置 classwt
,并且在测试集中先验向量为 (q1,q2) ,q3)?
最佳答案
could setting classwt parameter help when you have heavy unbalanced data - priors of classes differs strongly?
是的,设置 classwt 的值对于不平衡的数据集可能很有用。我同意 joran 的观点,即这些值被转换为采样训练数据的概率(根据 Breiman 在其原始文章中的论点)。
How set classwt when in training dataset with 3 classes you have vector of priors equal to (p1,p2,p3), and in test set priors are (q1,q2,q3)?
对于训练,您可以简单地指定
rf <- randomForest(x=x, y=y, classwt=c(p1,p2,p3))
对于测试集,不能使用先验:1)randomForest包的predict
方法中没有这样的选项; 2)权重仅对模型训练有意义,对预测没有意义。
关于r - R中RandomForest包中的RandomForest函数中的参数 'classwt'代表什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10112678/