0
0
ML Pythonprogramming~10 mins

First ML prediction (linear regression) 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 simple linear regression model using scikit-learn.

ML Python
from sklearn.linear_model import [1]
model = LinearRegression()
Drag options to blanks, or click blank then click option'
ADecisionTreeClassifier
BLogisticRegression
CLinearRegression
DKMeans
Attempts:
3 left
2fill in blank
medium

Complete the code to fit the linear regression model with features X and target y.

ML Python
model.[1](X, y)
Drag options to blanks, or click blank then click option'
Apredict
Bfit
Ctransform
Dscore
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to predict target values using the trained model.

ML Python
predictions = model.[1](X_test)
Drag options to blanks, or click blank then click option'
Afit
Bscore
Ctransform
Dpredict
Attempts:
3 left
4fill in blank
hard

Fill both blanks to calculate the mean squared error between true and predicted values.

ML Python
from sklearn.metrics import [1]
mse = [2](y_true, y_pred)
Drag options to blanks, or click blank then click option'
Amean_squared_error
Baccuracy_score
Cmean_absolute_error
Dr2_score
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a dictionary of predictions for each test sample with keys as sample indices.

ML Python
pred_dict = [1](i: [2] for i, [3] in enumerate(y_pred))
Drag options to blanks, or click blank then click option'
Adict
Bvalue
Ditem
Attempts:
3 left