How to balance classification using DecisionTreeClassifier?

前端 未结 2 1055
失恋的感觉
失恋的感觉 2021-02-15 13:41

I have a data set where the classes are unbalanced. The classes are either 0, 1 or 2.

How can I calculate the prediction error fo

2条回答
  •  生来不讨喜
    2021-02-15 13:47

    If you want to fully balance (treat each class as equally important) you can simply pass class_weight='balanced', as it is stated in the docs:

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

提交回复
热议问题