Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
2fill in blank
mediumComplete 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'
Attempts:
3 left
3fill in blank
hardFix 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'
Attempts:
3 left
4fill in blank
hardFill 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'
Attempts:
3 left
5fill in blank
hardFill 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'
Attempts:
3 left