需要安全防護措施嗎?
某家商店想根據他們預期在 2023 年黑色星期五(全年最大檔期)會有的買家數量,判斷是否需要升級安全作業規範。場內的最大容留人數上限是 250。每年黑色星期五,這家店都會請每位買家為購物體驗打分,而你正好取得了這份資料。
問卷資料集 foot_traffic 已經為你清理並載入。它包含欄位:year、visitors、average_experience_rating。
statsmodels.api 套件已匯入為 sm,同時還有 matplotlib.pyplot 作為 plt、pandas 作為 pd、以及 numpy 作為 np。
本練習屬於課程
使用 Python 分析問卷資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Define variable, x and y
x = foot_traffic.____.____
y = foot_traffic.____.____
# Add the constant term
x = ____.____(x)
# Perform .OLS() regression and fit
result = ____.____(y,x).____()
# Print the summary table
print(____.____())