Complete the code to split data into training and testing sets.
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)
The function train_test_split is used to split data into training and testing sets.
Complete the code to create a simple linear regression model.
from sklearn.linear_model import [1] model = LinearRegression()
LinearRegression is the class used to create a linear regression model.
Fix the error in the code to calculate mean squared error correctly.
from sklearn.metrics import mean_squared_error mse = mean_squared_error(y_true, [1])
The mean_squared_error function compares true values y_true with predicted values y_pred.
Fill both blanks to create a dictionary of squared errors for errors greater than 1.
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}The ** operator is used to square the error, and > checks if the error is greater than 1.
Fill all three blanks to create a dictionary of errors for predictions less than 0.5.
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}The error is calculated by subtracting predicted from true values, filtering predictions less than 0.5, and indices less than or equal to 10.
