Data Science Interview Preparation

🚀 Crack FAANG Interviews: Master Logistic Regression with This 3-Level Quiz Challenge (Score 90%+ to Prove You're Ready!)

Logistic Regression Quiz - Intermediate Level

Logistic Regression Quiz - Intermediate Level

Q1. Which metric is generally most appropriate for evaluating a logistic regression model on an imbalanced dataset?

A) Accuracy
B) Precision
C) Recall
D) F1-Score

Q2. What is the purpose of the ROC curve in logistic regression?

A) To evaluate regression loss
B) To assess correlation
C) To show trade-off between TPR and FPR
D) To rank features

Q3. What does the area under the ROC curve (AUC) represent?

A) Probability of true negative classification
B) Mean squared error of predictions
C) Ability to rank a randomly chosen positive instance higher than a negative one
D) Distribution of classes

Q4. What does L1 regularization do to logistic regression coefficients?

A) Adds Gaussian noise
B) Shrinks them to zero exactly, encouraging sparsity
C) Forces them to equal values
D) Converts them to binary

Q5. What is one advantage of L2 regularization over L1 in logistic regression?

A) It produces a sparse model
B) It performs automatic binning of variables
C) It encourages smaller, but non-zero coefficients, improving generalization
D) It ignores outliers better

Q6. Which scikit-learn parameter enables multi-class classification in LogisticRegression()?

A) binary=True
B) penalty='multi'
C) multi_class='ovr' or 'multinomial'
D) type='categorical'

Q7. How does logistic regression handle categorical features natively?

A) It converts them internally
B) It requires manual conversion like one-hot encoding
C) It only accepts numeric data
D) It maps strings to binary

Q8. What problem arises if the features are highly correlated in logistic regression?

A) Model becomes more accurate
B) Multicollinearity distorts coefficient estimates
C) Loss function does not converge
D) Sigmoid fails to activate

Q9. In logistic regression, increasing the regularization parameter C in scikit-learn does what?

A) Increases regularization strength
B) Decreases regularization strength
C) Increases model complexity penalty
D) Converts logistic regression to linear

Q10. If your logistic regression model is overfitting, what is one thing you should try first?

A) Use polynomial features
B) Decrease regularization
C) Add more features
D) Increase regularization

Detailed Explanations

  1. F1-score balances precision and recall and is better than accuracy on imbalanced data.
  2. ROC curve helps visualize classifier performance across thresholds.
  3. AUC measures how well the classifier ranks positive instances above negatives.
  4. L1 encourages sparsity, effectively removing unimportant features.
  5. L2 reduces model complexity without zeroing out coefficients completely.
  6. scikit-learn uses multi_class='ovr' or 'multinomial' for multi-class classification.
  7. Manual encoding (e.g., one-hot) is needed before applying logistic regression.
  8. Multicollinearity inflates standard errors of coefficients, making them unstable.
  9. In scikit-learn, C is the inverse of regularization strength.
  10. Increasing regularization helps simplify the model and reduce overfitting.
'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
Theme images by Barcin. Powered by Blogger.