Complete the code to calculate Mean Squared Error (MSE) between true and predicted values.
from sklearn.metrics import mean_squared_error mse = mean_squared_error(y_true, [1])
The Mean Squared Error function compares the true values y_true with the predicted values y_pred.
Complete the code to calculate Root Mean Squared Error (RMSE) from MSE.
import numpy as np rmse = np.sqrt([1])
RMSE is the square root of the Mean Squared Error (MSE), so we pass MSE inside np.sqrt().
Fix the error in the code to calculate R² score correctly.
from sklearn.metrics import r2_score score = r2_score([1], y_pred)
The R² score function compares the true values y_true with predicted values y_pred.
Fill both blanks to compute RMSE using MSE stored in variable mse.
import numpy as np rmse = np.[1]([2])
np.mean or np.sum instead of np.sqrt.mse.RMSE is the square root of the MSE value stored in mse. Use np.sqrt(mse).
Fill all three blanks to create a dictionary with R² score and RMSE from predictions.
from sklearn.metrics import r2_score, mean_squared_error import numpy as np results = { '[1]': r2_score(y_true, y_pred), '[2]': np.sqrt(mean_squared_error(y_true, y_pred)), '[3]': mean_squared_error(y_true, y_pred) }
The dictionary keys should be R2 for R² score, RMSE for root mean squared error, and MSE for mean squared error.
