How it works...
In this recipe, we identified a linear relationship between an independent and a dependent variable using scatter and residual plots. To proceed with this recipe, we created a toy dataframe with an independent variable x that is normally distributed and linearly related to a dependent variable y. Next, we created a scatter plot between x and y, built a linear regression model between x and y, and obtained the predictions. Finally, we calculated the residuals and plotted the residuals versus the variable and the residuals histogram.
To generate the toy dataframe, we created an independent variable x that is normally distributed using NumPy's random.randn(), which extracts values at random from a normal distribution. Then, we ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access