0
0
ML Pythonprogramming~10 mins

Linear regression concept 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 LinearRegression
model = LinearRegression([1])
Drag options to blanks, or click blank then click option'
Afit_intercept=True
Bn_estimators=100
Crandom_state=42
Dactivation='relu'
Attempts:
3 left
2fill in blank
medium

Complete the code to train the linear regression model on data X and 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 make predictions using the trained model.

ML Python
predictions = model.[1](X_test)
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 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 coefficients for each feature with their names.

ML Python
coef_dict = {{ [1]: [2] for [3], coef in zip(feature_names, model.coef_)}
Drag options to blanks, or click blank then click option'
Afeature
Bcoef
Cfeature_names
Dmodel
Attempts:
3 left