0
0
ML Pythonml~10 mins

Multi-label classification 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 correct multi-label classifier from scikit-learn.

ML Python
from sklearn.multioutput import [1]
Drag options to blanks, or click blank then click option'
AMultiOutputClassifier
BRandomForestClassifier
CLogisticRegression
DKNeighborsClassifier
Attempts:
3 left
💡 Hint
Common Mistakes
Importing a single-label classifier instead of a multi-label one.
Confusing RandomForestClassifier with MultiOutputClassifier.
2fill in blank
medium

Complete the code to create a multi-label classifier using a decision tree as the base estimator.

ML Python
from sklearn.tree import DecisionTreeClassifier
from sklearn.multioutput import MultiOutputClassifier

model = MultiOutputClassifier([1]())
Drag options to blanks, or click blank then click option'
ADecisionTreeClassifier
BRandomForestClassifier
CLogisticRegression
DKNeighborsClassifier
Attempts:
3 left
💡 Hint
Common Mistakes
Using a classifier not imported or unrelated to the task.
Forgetting to instantiate the classifier with parentheses.
3fill in blank
hard

Fix the error in the code to correctly fit the multi-label classifier on data X and labels Y.

ML Python
model = MultiOutputClassifier(DecisionTreeClassifier())
model.[1](X, Y)
Drag options to blanks, or click blank then click option'
Atransform
Bpredict
Cfit
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of fit to train the model.
Using transform which is not applicable here.
4fill in blank
hard

Fill both blanks to compute the accuracy score for multi-label classification.

ML Python
from sklearn.metrics import [1]

score = [2](Y_true, Y_pred)
Drag options to blanks, or click blank then click option'
Aaccuracy_score
Bf1_score
Croc_auc_score
Dmean_squared_error
Attempts:
3 left
💡 Hint
Common Mistakes
Using regression metrics like mean_squared_error for classification.
Using roc_auc_score which is for binary or multilabel-indicator but needs special handling.
5fill in blank
hard

Fill all three blanks to create a multi-label classifier with logistic regression, fit it, and predict labels.

ML Python
from sklearn.linear_model import [1]
from sklearn.multioutput import MultiOutputClassifier

model = MultiOutputClassifier([2]())
model.[3](X_train, Y_train)
Y_pred = model.predict(X_test)
Drag options to blanks, or click blank then click option'
ALogisticRegression
BDecisionTreeClassifier
Cfit
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of fit to train the model.
Using a different base estimator than imported.