2
$\begingroup$

I am working on a classification task with an imbalanced dataset. I am using Sklearn's ensemble RandomForestClassifier and set its class weight to Balanced.

My question is, when I then GridSearch it, is it necessary to use Stratified K Fold or is the class weight parameter already taking care of the imbalanced class problem?

$\endgroup$

1 Answer 1

2
$\begingroup$

class_weight is used by random forest to assess the cost/gain when splitting the nodes of the trees, i.e. to quantify the misclassifications so that greedy split decisions can be made. However, this mechanism is not related to validation fold splits. If you want to stratify your classes into folds so that each fold preserve the approximate class proportions, you need to use StratifiedKFold as you also pointed out.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.