How to explain an outcome with several drivers at once: the least-squares line, multiple regression with statsmodels, dummy variables for categories, and interactions. Then the trap behind every coefficient (what it holds fixed) and how to turn a model into a decision in riyals.
Slides¶
Present full screen Download the PDF
Click or tap the slide to move forward, its left edge to go back; the arrow keys work too.
Reading¶
Regression: What Drives Daily Sales builds the models of the lecture step by step on a year of Qahwa House’s daily sales: why the simple regression says that higher prices sell more cups, how the branch and the temperature turn that slope negative, why one promotion coefficient hides a promotion that pays only at the University branch, and what a riyal on the price is worth.
Lab 6: Linear regression with statsmodels¶
The manager asks two questions: should Qahwa House raise its drink prices by 1 SAR, and should every branch keep the second cup half price promotion? You fit simple and multiple regressions, add dummy variables and an interaction, predict a day with its interval, and turn the coefficients into riyals per day before writing a three-sentence recommendation.
Open the lab, then use its Open in Colab button.
Data: qahwa
_daily _2025 .csv (1,460 rows, one per branch and day of 2025, with the price tested that month, the temperature and the promotion). The notebook downloads it by itself. Submit before the next lab session. The solutions are for checking your work afterwards.
Next week¶
Model validation and classification: testing a model on data it has not seen, and predicting yes/no outcomes such as customer churn.