Get startedGet started for free

Visualizing multiple models

In the last two exercises, you ran models for each category of house ages separately, then calculated predictions for each model. Now it's time to visualize those predictions to see how they compare.

When you use sns.lmplot() with the hue argument set to the categorical variable, you get multiple trend lines, each with their own slope. This is in contrast with the parallel slopes model you saw in Chapter 1, where all models had the same slope.

taiwan_real_estate is available. prediction_data is loaded as a concatenated DataFrame of all house ages.

This exercise is part of the course

Intermediate Regression with statsmodels in Python

View Course

Hands-on interactive exercise

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

# Plot the trend lines of price_twd_msq vs. n_convenience for each house age category
____(x=____,
     y=____,
     data=____,
     hue=____,
     ci=____,
     legend_out=False)

plt.show()
Edit and Run Code