All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.
All our activities include solutions with explanations on how they work and why we chose them.
Set the random_state parameter to 0 value for reproducibility. Store this variable in random_state and then use it in the function.
Store the values in the variables in
X_train,X_test,y_trainandy_test.
Create an instance of the LinearRegression and store the model in lr.
It's time to train the linear regression model using the training dataset.
Use the trained model to make predictions on the test data. Store the prediction in y_pred.
Calculate the following regression evaluation metrics using the true target values (y_test) and the predicted values:
Store the result in MSE, RMSE and R2 variables.