상호작용을 사용한 예측
지금까지 만든 다른 회귀 모델과 마찬가지로, 예측을 만드는 과정이 가장 흥미롭습니다. 다행히도 이 경우의 코드 흐름은 상호작용이 없는 경우와 동일해요. statsmodels가 추가 지시 없이도 상호작용 항을 계산해 줍니다. 한 가지 기억해야 할 점은 설명 변수들의 조합을 만드는 요령뿐이에요.
적합된 모델 mdl_price_vs_both_inter가 준비되어 있고, itertools.product가 로드되어 있습니다.
이 연습은 강의의 일부입니다
Python의 statsmodels로 배우는 중급 회귀
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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)