LoslegenKostenlos starten

Visualizing parallel slopes

The two plots in the previous exercise gave very different predictions: one gave a predicted response that increased linearly with a numeric variable; the other gave a fixed response for each category. The only sensible way to reconcile these two conflicting predictions is to incorporate both explanatory variables in the model at once.

When it comes to a linear regression model with a numeric and a categorical explanatory variable, seaborn doesn't have an easy, "out of the box" way to show the predictions.

taiwan_real_estate is available and mdl_price_vs_both is available as a fitted model. seaborn is imported as sns and matplotlib.pyplot is imported as plt.

Diese Übung ist Teil des Kurses

<Kurs>Intermediate Regression with statsmodels in Python</Kurs>
Kurs ansehen

Interaktive praktische Übung

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

# Extract the model coefficients, coeffs
coeffs = ____

# Print coeffs
print(coeffs)

# Assign each of the coeffs
____, ____, ____, ____ = ____
Code bearbeiten und ausführen