Exercise: Visualizing Regression Plots
Explore how to visualize regression models with Plotly by creating scatter plots with OLS trendlines and rolling mean smoothers. Understand model fits by comparing linear regression and gradient boosting regression results using subplots. Gain hands-on experience interpreting relevant statistics like R squared.
We'll cover the following...
We'll cover the following...
Exercise 1
Create a scatter plot with the Sales variable plotted against TV. Include a red trendline of the line of best fit using Ordinary Least Squares (OLS). What is the value?
Solution
-
A scatter plot is created using the
px.scatter()function on line 2 with theadvertisingDataFrame. Thexparameter is set toTVto specify the x-axis data, and theyparameter is set toSalesto specify the y-axis data. Thetrendlineparameter is set tools...