0
0
ML Pythonprogramming~10 mins

Multiple 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 import the linear regression model from scikit-learn.

ML Python
from sklearn.linear_model import [1]
Drag options to blanks, or click blank then click option'
AKNeighborsClassifier
BLogisticRegression
CDecisionTreeRegressor
DLinearRegression
Attempts:
3 left
2fill in blank
medium

Complete the code to create a linear regression model instance.

ML Python
model = [1]()
Drag options to blanks, or click blank then click option'
ARandomForestRegressor
BLogisticRegression
CLinearRegression
DKMeans
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to train the model with features X and target y.

ML Python
model.fit([1], y)
Drag options to blanks, or click blank then click option'
AX
By
Cmodel
Dfit
Attempts:
3 left
4fill in blank
hard

Fill both blanks to predict target values and calculate the mean squared error.

ML Python
predictions = model.[1](X_test)
mse = mean_squared_error(y_test, [2])
Drag options to blanks, or click blank then click option'
Apredict
Bpredictions
Cfit
DX_test
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a dictionary of coefficients, intercept, and R² score.

ML Python
results = {
    'coefficients': model.[1],
    'intercept': model.[2],
    'r2_score': model.[3](X_test, y_test)
}
Drag options to blanks, or click blank then click option'
Acoef_
Bintercept_
Cscore
Dfit
Attempts:
3 left