Get startedGet started for free

Visualizing predictions

The prediction DataFrame you created contains a column of explanatory variable values and a column of response variable values. That means you can plot it on the same scatter plot of response versus explanatory data values.

prediction_data is available. The code for the plot you created using sns.regplot() in Chapter 1 is shown.

This exercise is part of the course

Introduction to Regression with statsmodels in Python

View Course

Exercise instructions

  • Create a new figure to plot multiple layers.
  • Extend the plotting code to add points for the predictions in prediction_data. Color the points red.
  • Display the layered plot.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a new figure, fig
fig = ____

sns.regplot(x="n_convenience",
            y="price_twd_msq",
            data=taiwan_real_estate,
            ci=None)
# Add a scatter plot layer to the regplot
sns.____(____)

# Show the layered plot
plt.____()
Edit and Run Code