Subdomain 1.2: Loss functions and splitting criteria
1.You are training a LogisticRegression model on an imbalanced dataset and want to penalize misclassifications of the minority class more. Which parameter should you set?
- A.class_weight='balanced'
- B.loss='hinge'
- C.penalty='l1'
- D.C=0.1
Show answer & explanation
Correct answer: A — class_weight='balanced'
- A. Setting class_weight='balanced' automatically adjusts weights inversely proportional to class frequencies, increasing the penalty for misclassifying minority class samples. This is the standard parameter for handling class imbalance in scikit-learn's LogisticRegression.
- B. Incorrect. loss='hinge' is not a valid parameter for LogisticRegression; it is associated with SVM-style classifiers such as SGDClassifier or LinearSVC. It does not address class imbalance in logistic regression.
- C. Incorrect. penalty='l1' controls the type of regularization (L1) applied to the model coefficients, encouraging sparsity. It does not change the relative cost of misclassifying one class versus another.
- D. Incorrect. C is the inverse of regularization strength; lowering it increases regularization and raising it decreases regularization. It does not specifically penalize minority class errors more.