LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Intermediate Regression with statsmodels in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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()
Code bearbeiten und ausführen