इंटरैक्शंस के साथ प्रीडिक्शन
जैसा कि आपने अब तक बनाए हर रिग्रेशन मॉडल के साथ किया है, सबसे मज़ेदार हिस्सा प्रीडिक्शन करना है। अच्छी बात यह है कि इस केस में कोड का फ्लो बिना इंटरैक्शन वाले केस जैसा ही रहेगा — statsmodels आपके किसी अतिरिक्त निर्देश के बिना ही इंटरैक्शन की गणना कर सकता है। बस एक बात याद रखें: व्याख्यात्मक वैरिएबल्स के संयोजनों (combinations) को बनाने वाला ट्रिक उपयोग करना है।
mdl_price_vs_both_inter एक फिट किया हुआ मॉडल के रूप में उपलब्ध है, itertools.product लोड किया गया है।
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Regression with statsmodels in Python
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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)