Complete the code to create a supervised learning model using scikit-learn.
from sklearn.linear_model import LinearRegression model = [1]()
LinearRegression is a supervised learning model used for predicting continuous values.
Complete the code to perform unsupervised clustering on data.
from sklearn.cluster import [1] model = [1](n_clusters=3)
KMeans is an unsupervised learning algorithm used for clustering data into groups.
Fix the error in the reinforcement learning agent initialization.
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)
QAgent is the reinforcement learning agent class that needs to be instantiated.
Fill both blanks to complete the code that fits a supervised model and predicts.
model = [1]() model.[2](X_train, y_train) predictions = model.predict(X_test)
LinearRegression is the supervised model, and fit() trains it on data.
Fill all three blanks to create an unsupervised model, fit it, and transform data.
from sklearn.decomposition import [1] model = [1](n_components=2) X_reduced = model.[2](X) print(X_reduced.shape) # Should print (n_samples, [3])
PCA reduces data dimensions; fit_transform fits and transforms data; 2 is the number of components.
