0
0
ML Pythonml~10 mins

Semi-supervised learning basics 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 semi-supervised learning module from scikit-learn.

ML Python
from sklearn import [1]
Drag options to blanks, or click blank then click option'
Asemi_supervised
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'semi-supervised' with a dash instead of underscore.
Trying to import from 'supervised' or 'unsupervised' instead.
2fill in blank
medium

Complete the code to create a LabelPropagation model instance.

ML Python
model = [1]()
Drag options to blanks, or click blank then click option'
ALabelPropagation
BLabelSpreading
CKNeighborsClassifier
DRandomForestClassifier
Attempts:
3 left
💡 Hint
Common Mistakes
Using supervised classifiers like KNeighborsClassifier or RandomForestClassifier.
Confusing LabelPropagation with LabelSpreading.
3fill in blank
hard

Fix the error in the code to fit the semi-supervised model with data X and labels y, where unlabeled points are marked as -1.

ML Python
model.fit([1], y)
Drag options to blanks, or click blank then click option'
Amodel
By
CX
Dunlabeled
Attempts:
3 left
💡 Hint
Common Mistakes
Passing labels y as the first argument instead of X.
Passing the model itself or an undefined variable.
4fill in blank
hard

Fill both blanks to create a dictionary of predicted labels for unlabeled data points.

ML Python
predictions = {i: model.[1]()[i] for i in range(len([2])) if y[i] == -1}
Drag options to blanks, or click blank then click option'
Apredict
BX
Cfit
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' or 'score' instead of 'predict'.
Iterating over y instead of X.
5fill in blank
hard

Fill all three blanks to create a semi-supervised learning pipeline with LabelSpreading, fit it, and predict labels.

ML Python
from sklearn.semi_supervised import [1]
model = [2](kernel=[3])
model.fit(X, y)
predicted_labels = model.predict(X)
Drag options to blanks, or click blank then click option'
ALabelSpreading
B'rbf'
C'linear'
DLabelPropagation
Attempts:
3 left
💡 Hint
Common Mistakes
Using LabelPropagation instead of LabelSpreading.
Using 'linear' kernel which is less common here.