Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a supervised learning model using scikit-learn.
ML Python
from sklearn.linear_model import LinearRegression model = [1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to perform unsupervised clustering on data.
ML Python
from sklearn.cluster import [1] model = [1](n_clusters=3)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the reinforcement learning agent initialization.
ML Python
class QAgent: def __init__(self, learning_rate=0.1, discount_factor=0.9): self.learning_rate = learning_rate self.discount_factor = discount_factor agent = [1](learning_rate=0.1, discount_factor=0.9)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to complete the code that fits a supervised model and predicts.
ML Python
model = [1]() model.[2](X_train, y_train) predictions = model.predict(X_test)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to create an unsupervised model, fit it, and transform data.
ML Python
from sklearn.decomposition import [1] model = [1](n_components=2) X_reduced = model.[2](X) print(X_reduced.shape) # Should print (n_samples, [3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left