how to use classwt in randomForest of R?

后端 未结 3 1005
南笙
南笙 2021-02-05 03:24

I have a highly imbalanced data set with target class instances in the following ratio 60000:1000:1000:50 (i.e. a total of 4 classes). I want to use randomFor

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 04:19

    Random forests are probably not the right classifier for your problem as they are extremely sensitive to class imbalance.

    When I have an unbalanced problem I usually deal with it using sampsize like you tried. However I make all the strata equal size and I use sampling without replacement. Sampling without replacement is important here, as otherwise samples from the smaller classes will contain many more repetitions, and the class will still be underrepresented. It may be necessary to increase mtry if this approach leads to small samples, sometimes even setting it to the total number of features.

    This works quiet well when there are enough items in the smallest class. However, your smallest class has only 50 items. I doubt you would get useful results with sampsize=c(50,50,50,50).

    Also classwt has never worked for me.

提交回复
热议问题