Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'semi-supervised' with a dash instead of underscore.
Trying to import from 'supervised' or 'unsupervised' instead.
✗ Incorrect
The semi-supervised learning module in scikit-learn is called 'semi_supervised'.
2fill in blank
mediumComplete the code to create a LabelPropagation model instance.
ML Python
model = [1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using supervised classifiers like KNeighborsClassifier or RandomForestClassifier.
Confusing LabelPropagation with LabelSpreading.
✗ Incorrect
LabelPropagation is a common semi-supervised learning model in scikit-learn.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing labels y as the first argument instead of X.
Passing the model itself or an undefined variable.
✗ Incorrect
The fit method requires the feature data X as the first argument.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' or 'score' instead of 'predict'.
Iterating over y instead of X.
✗ Incorrect
We use model.predict() to get predicted labels and iterate over X to find unlabeled points.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using LabelPropagation instead of LabelSpreading.
Using 'linear' kernel which is less common here.
✗ Incorrect
LabelSpreading is imported and instantiated with kernel='rbf' for smooth label spreading.