0
0
ML Pythonprogramming~10 mins

Types of ML (supervised, unsupervised, reinforcement) 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 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'
AKMeans
BLinearRegression
CQAgent
DPCA
Attempts:
3 left
2fill in blank
medium

Complete 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'
ALinearRegression
BDecisionTree
CQAgent
DKMeans
Attempts:
3 left
3fill in blank
hard

Fix 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'
AQAgent
BKMeans
CLinearRegression
DPCA
Attempts:
3 left
4fill in blank
hard

Fill 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'
ALinearRegression
Bfit
Ctransform
DKMeans
Attempts:
3 left
5fill in blank
hard

Fill 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'
APCA
Bfit_transform
C2
Dfit
Attempts:
3 left