Session Ready
Exercise

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.

Instructions 1/2
undefined XP
  • 1
  • 2
  • Create n_convenience as an array of numbers from 0 to 10.
  • Extract the unique values of the house_age_years column of taiwan_real_estate into the array house_age_years.
  • Create p, which should contain the Cartesian product of all values of n_convenience and house_age_years.
  • Transform p to a DataFrame and name the columns "n_convenience" and "house_age_years".