1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Regression with statsmodels in Python

Exercise

Predicting with interactions

As with every other regression model you've created, the fun part is making predictions. Fortunately, the code flow for this case is the same as the one without interactions — statsmodels can handle calculating the interactions without any extra prompting from you. The only thing you need to remember is the trick for getting combinations of explanatory variables.

mdl_price_vs_both_inter is available as a fitted model, itertools.product is loaded.

Instructions 1/3

undefined XP
    1
    2
    3

Create the DataFrame explanatory_data, formed from all combinations of the following variables:

  • n_convenience should take the numbers zero to ten.
  • house_age_years should take the unique values of the house_age_years column of taiwan_real_estate.