1. Home
  2. Data Science
  3. Scikit-learn
  4. What does setting class_weight="balanced" do in a…

Added 30 Nov -0001

What does setting class_weight="balanced" do in a scikit-learn classifier?

  1. It forces the predicted probability threshold to 0.5
  2. It weights classes inversely to their frequency Correct answer
  3. It duplicates minority rows until classes are equal
  4. It removes majority rows before fitting

Correct answer

B. It weights classes inversely to their frequency

17 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs