Predicting with a parallel slopes model
While seaborn
can automatically show you model predictions using sns.regplot()
, in order to get those values to program with, you'll need to do the calculations yourself.
Just as with the case of a single explanatory variable, the workflow has two steps: create a DataFrame of explanatory variables, then add a column of predictions.
taiwan_real_estate
is available and mdl_price_vs_both
is available as a fitted model. seaborn
, ols()
, matplotlib.pyplot
, pandas
, and numpy
are loaded as their default aliases. This will also be the case for the remainder of the course. In addition, ìtertools.product
is available as well.
This exercise is part of the course
Intermediate Regression with statsmodels in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create n_convenience as an array of numbers from 0 to 10
n_convenience = ____
# Extract the unique values of house_age_years
house_age_years = ____
# Create p as all combinations of values of n_convenience and house_age_years
p = ____(____, ____)
# Transform p to a DataFrame and name the columns
explanatory_data = ____
print(explanatory_data)