Now that you have built the linear model, you can move ahead with the next steps. Now, building the model on the train set has two parts - fitting a line and validating the assumptions of regression.
Recall that one of the assumptions that you studied was that the error terms should be normally distributed with mean equal to 0. So once you have built the model, you'd need to verify if your model is not violating this assumption. And doing this is fairly simple - you just plot a histogram of the error terms to check whether they are normally distributed. And another assumption was that the error terms should be independent of each other. Again for this, you need to plot the error terms, this time with either of X or y to check for any patterns. Let's see all of this in action in the following video.
The residuals are normally distributed, and there are no visible patterns in the error terms (except for the fact that the variance seems to be increasing a little for the higher values). So, this model fit looks good. Let's go ahead and make predictions on the test set.
You will use the 'predict()' function present in 'statsmodels.api' for the same.