Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the mean squared error (MSE) between predictions and true values.
ML Python
mse = ((predictions - true_values) [1] 2).mean()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to split data into training and testing sets using scikit-learn.
ML Python
from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=[1], random_state=42)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to train a linear regression model and make predictions.
ML Python
from sklearn.linear_model import LinearRegression model = LinearRegression() model.[1](X_train, y_train) predictions = model.predict(X_test)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps model complexity to training error.
ML Python
errors = {complexity: model_errors[complexity] [1] for complexity in model_errors if model_errors[complexity] [2] 0} Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill the blanks to calculate bias, variance, and total error from predictions.
ML Python
bias = (([1] - true_values) ** 2).mean() variance = predictions.var(axis=0).mean() total_error = bias + [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left