0
0
ML Pythonprogramming~10 mins

Logistic regression in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the logistic regression model from scikit-learn.

ML Python
from sklearn.linear_model import [1]
Drag options to blanks, or click blank then click option'
AKNeighborsClassifier
BLinearRegression
CDecisionTreeClassifier
DLogisticRegression
Attempts:
3 left
2fill in blank
medium

Complete the code to create a logistic regression model with default settings.

ML Python
model = [1]()
Drag options to blanks, or click blank then click option'
ALinearRegression
BRandomForestClassifier
CLogisticRegression
DSVC
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to fit the logistic regression model on features X and labels y.

ML Python
model.[1](X, y)
Drag options to blanks, or click blank then click option'
Afit
Btransform
Cpredict
Dscore
Attempts:
3 left
4fill in blank
hard

Complete the code to predict labels for X_test and calculate accuracy against y_test.

ML Python
predictions = model.[1](X_test)
accuracy = accuracy_score(y_test, predictions,)
Drag options to blanks, or click blank then click option'
Apredict
B)
C,
Dpredict_proba
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a logistic regression with L2 penalty, fit it, and print the accuracy score.

ML Python
model = LogisticRegression(penalty=[1])
model.[2](X_train, y_train)
print(accuracy_score(y_train, model.[3](X_train)))
Drag options to blanks, or click blank then click option'
A'l2'
Bfit
Cpredict
D'l1'
Attempts:
3 left