Unbalanced classification using RandomForestClassifier in sklearn

前端 未结 4 1612
借酒劲吻你
借酒劲吻你 2020-12-07 15:44

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 e

4条回答
  •  半阙折子戏
    2020-12-07 16:20

    Use the parameter class_weight='balanced'

    From sklearn documentation: The balanced mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))

提交回复
热议问题