0
0
ML Pythonprogramming~10 mins

Overfitting and underfitting 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 split data into training and testing sets.

ML Python
from sklearn.model_selection import [1]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
Drag options to blanks, or click blank then click option'
Atrain_test_split
Bcross_val_score
CGridSearchCV
DStandardScaler
Attempts:
3 left
2fill in blank
medium

Complete the code to create a simple linear regression model.

ML Python
from sklearn.linear_model import [1]

model = LinearRegression()
Drag options to blanks, or click blank then click option'
ADecisionTreeClassifier
BLinearRegression
CLogisticRegression
DKNeighborsClassifier
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to calculate mean squared error correctly.

ML Python
from sklearn.metrics import mean_squared_error

mse = mean_squared_error(y_true, [1])
Drag options to blanks, or click blank then click option'
Ay_pred
By_train
CX_test
Dmodel
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a dictionary of squared errors for errors greater than 1.

ML Python
squared_errors = {i: (y_true[i] - y_pred[i])[1]2 for i in range(len(y_true)) if (y_true[i] - y_pred[i]) [2] 1}
Drag options to blanks, or click blank then click option'
A**
B>
C<
D+
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a dictionary of errors for predictions less than 0.5.

ML Python
errors = {i: y_true[i] [1] y_pred[i] for i in range(len(y_true)) if y_pred[i] [2] 0.5 and i [3] 10}
Drag options to blanks, or click blank then click option'
A-
B<
C<=
D+
Attempts:
3 left