I'm dealing with a binary classification problem with a balanced data set, however false positives are much more costly than false negatives. Let's just say that an FP is in general 3 times more costly than an FN and the response variable = 1 means a positive identification. How should I set the class_weight parameter in sklearn's RandomForest to reflect this ? From my understanding, I would say:

class_weight = {0:1.0,1:3.0}

I'm not sure if I understand this parameter correctly or should it be the inverse ?



1 Answer 1


\begin{array} {|r|r|} \hline - &(1) &(0) \\ \hline (1) &- &FP\\ \hline (0) &FN &-\\ \hline \end{array}

Rows elements are Y_true and column is Y_pred.

FP means, we predicted Positive and it came out False i.e. Class was Negative(0 here).

It means we don't want the Model to mis-classify the Negative class.
So, it implies, we will put a bigger penalty for the Negative class. Hence,

class_weight = {0:3.0.0,1:1.0}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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