CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Intermediate Regression with statsmodels in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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()
Modifier et exécuter le code