Proper use of “class_weight” parameter in Random Forest classifier
我有一个多类别分类问题,我正在尝试使用随机森林分类器。目标严重失衡,并且具有以下分布-
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 34108 4 6748 5 2458 3 132 2 37 7 11 6 6 |
现在,我为RandomForest分类器使用" class_weight "参数,据我了解,与类相关的权重采用{class_label:weight}
的形式
因此,以下是正确的方法:
1 | rfc = RandomForestClassifier(n_estimators = 1000, class_weight = {1:0.784, 2: 0.00085, 3: 0.003, 4: 0.155, 5: 0.0566, 6: 0.00013, 7: 0.000252}) |
感谢您的帮助!
如果选择
在您的示例中,您对权重过高的类的权重要高于权重不足的类。我相信这与您要实现的目标相反。
计算每个类别的权重的基本公式是