0
0
ML Pythonprogramming~10 mins

Linear regression with scikit-learn 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 LinearRegression class from scikit-learn.

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

Complete the code to create a LinearRegression model instance.

ML Python
model = [1]()
Drag options to blanks, or click blank then click option'
ARandomForestRegressor
BSVC
CLinearRegression
DKNeighborsClassifier
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.[1](X, y)
Drag options to blanks, or click blank then click option'
Apredict
Bfit
Ctransform
Dscore
Attempts:
3 left
4fill in blank
hard

Fill both blanks to predict target values and calculate the model's R² score.

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

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

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
Dpredict
Attempts:
3 left