Unbalanced classification using RandomForestClassifier in sklearn
问题 I have a dataset where the classes are unbalanced. The classes are either '1' or '0' where the ratio of class '1':'0' is 5:1. How do you calculate the prediction error for each class and the rebalance weights accordingly in sklearn with Random Forest, kind of like in the following link: http://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm#balance 回答1: You can pass sample weights argument to Random Forest fit method sample_weight : array-like, shape = [n_samples] or None Sample