1. Home
  2. Data Science
  3. Scikit-learn
  4. LogisticRegression(class_weight='balanced') is fitted on…

Added 30 Nov -0001

LogisticRegression(class_weight='balanced') is fitted on 1000 rows with 100 positives. What weight does the positive class receive?

  1. 1.0, because balanced weighting only rescales the intercept term of the model
  2. 0.1, because the minority class is down-weighted to match the majority count
  3. 5.0, computed as n_samples divided by the product of classes and positives Correct answer
  4. 10.0, computed as the ratio of negatives to positives in the training data

Correct answer

C. 5.0, computed as n_samples divided by the product of classes and positives

16 views

MCQSEXAM

Explanation

Balanced class weights are n_samples/(n_classes * n_class), so with 1000 rows, two classes and 100 positives the positive weight is 1000/(2*100) = 5.0, while the negative weight is 1000/(2*900) = 0.56. This rebalances the loss without resampling any rows. It also shifts predicted probabilities, so recalibrate if those are reported as real risks.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? 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