What does setting class_weight="balanced" do in a scikit-learn classifier?
Correct answer
B. It weights classes inversely to their frequency
17 views
B. It weights classes inversely to their frequency
17 views
The balanced setting computes weights as inversely proportional to class frequencies and applies them to the loss, so errors on the rare class cost more and the model stops ignoring it. Unlike resampling, no rows are added or deleted, so the original data is preserved and the effect appears in the fitted coefficients. The alternative is manual weights, or resampling methods such as SMOTE applied inside the training folds only.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is B? Ask here and get an explanation.