0
0
ML Pythonprogramming~20 mins

Logistic regression in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Logistic Regression Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the output of logistic regression
What does the output of a logistic regression model represent?
AThe probability that the input belongs to the positive class
BThe exact class label predicted by the model
CThe distance of the input from the decision boundary in feature space
DThe sum of squared errors between predicted and actual values
Attempts:
2 left
Predict Output
intermediate
2:00remaining
Output of logistic regression prediction code
What is the output of this Python code using scikit-learn's LogisticRegression?
ML Python
from sklearn.linear_model import LogisticRegression
import numpy as np

X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]])
y = np.array([0, 0, 1, 1])
model = LogisticRegression()
model.fit(X, y)
preds = model.predict(np.array([[1, 2], [3, 5]]))
print(preds.tolist())
A[1, 1]
B[1, 0]
C[0, 0]
D[0, 1]
Attempts:
2 left
Hyperparameter
advanced
2:00remaining
Choosing the regularization parameter in logistic regression
Which effect does increasing the regularization strength (C parameter) in scikit-learn's LogisticRegression have?
AIt decreases regularization, allowing the model to fit training data more closely
BIt changes the number of iterations during training
CIt changes the learning rate of the model
DIt increases regularization, forcing the model to be simpler
Attempts:
2 left
Metrics
advanced
2:00remaining
Interpreting logistic regression evaluation metrics
If a logistic regression model has a high accuracy but low recall on the positive class, what does this imply?
AThe model performs well on both positive and negative classes
BThe model correctly identifies most positive cases but misclassifies many negatives
CThe model misses many positive cases but correctly identifies most negatives
DThe model has overfitted the training data
Attempts:
2 left
🔧 Debug
expert
2:00remaining
Identifying the cause of poor logistic regression convergence
Given this code snippet, why might the logistic regression model fail to converge?
ML Python
from sklearn.linear_model import LogisticRegression
import numpy as np

X = np.random.rand(1000, 50)
y = np.random.randint(0, 2, 1000)
model = LogisticRegression(max_iter=10)
model.fit(X, y)
AThe input features X contain random values causing errors
Bmax_iter is too low for the model to converge on this data
CThe target y has only two classes which logistic regression cannot handle
DThe model requires normalization of X before fitting
Attempts:
2 left