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.
Este exercício faz parte do curso
Intermediate Regression with statsmodels in Python
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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 it
print(explanatory_data)