R 中 RandomForest 包中的 RandomForest 函数中的参数“classwt"代表什么? [英] What does the parameter 'classwt' in RandomForest function in RandomForest package in R stand for?

查看:41
本文介绍了R 中 RandomForest 包中的 RandomForest 函数中的参数“classwt"代表什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

randomforest::randomforest() 的帮助页面说:

classwt - 类的先验.不需要加起来一.在回归中忽略."

"classwt - Priors of the classes. Need not add up to one. Ignored for regression."

当您有严重的不平衡数据时,可以设置 classwt 参数帮助,即.类的先验差异很大?

Could setting the classwt parameter help when you have heavy unbalanced data, ie. priors of classes differs strongly ?

在具有 3 个类的数据集上训练模型时,我应该如何设置 classwt,其中先验向量等于 (p1,p2,p3),并且在测试集中先验是 (q1,q2,q3)?

How should I set classwt when training a model on a dataset with 3 classes with a vector of priors equal to (p1,p2,p3), and in test set priors are (q1,q2,q3)?

推荐答案

当您有严重的不平衡数据时,设置 classwt 参数是否有帮助 - 类的先验差异很大?

could setting classwt parameter help when you have heavy unbalanced data - priors of classes differs strongly?

是的,设置 classwt 的值可能对不平衡的数据集很有用.我同意 joran 的观点,即这些值在采样训练数据的概率中进行了转换(根据 Breiman 在其原始文章中的论点).

Yes, setting values of classwt could be useful for unbalanced datasets. And I agree with joran, that these values are trasformed in probabilities for sampling training data (according Breiman's arguments in his original article).

在具有 3 个类的训练数据集中,您的先验向量等于 (p1,p2,p3) 并且在测试集中先验是 (q1,q2,q3) 时,如何设置 classwt?

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)?

对于训练,您可以简单地指定

For training you can simply specify

rf <- randomForest(x=x, y=y, classwt=c(p1,p2,p3))

对于测试集,不能使用先验:1)在randomForest包的predict方法中没有这样的选项;2)权重只对模型的训练有意义,对预测没有意义.

For test set no priors can be used: 1) there is no such option in predict method of randomForest package; 2) weights have only sense for training of the model and not for prediction.

这篇关于R 中 RandomForest 包中的 RandomForest 函数中的参数“classwt"代表什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆