LogisticRegression(class_weight='balanced') is fitted on 1000 rows with 100 positives. What weight does the positive class receive?
Correct answer
C. 5.0, computed as n_samples divided by the product of classes and positives
16 views
C. 5.0, computed as n_samples divided by the product of classes and positives
16 views
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.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.