Lab – Sales Forecasting#
Where data meets drama, and revenue meets regression! 😎
🎬 The Business Scenario#
Congratulations — you’ve just been promoted to Data Science Intern of the Year at Acme Retail Co. 🎉
Your boss (who once said “AI is just fancy Excel”) wants you to predict monthly sales using marketing spend, pricing, and seasonal factors.
Your mission:
Build a simple but effective regression model to forecast sales, explain it clearly, and make it look fancy on a dashboard so everyone thinks it’s magic. ✨
🧾 Step 1. Load the Data#
You’ve been handed a “beautifully messy” Excel file by the finance team (of course 🙃).
📊 Expected columns:
MonthTV_SpendSocial_Media_SpendDiscount_PercentSeasonSales
🧹 Step 2. Clean the Data#
Finance swore the data was “clean.” You’ll find out soon enough.
🧽 Handle missing values or weird outliers:
✅ Tip: Don’t delete too much — remember, data is like gossip; even the noisy parts tell a story. 😏
🔍 Step 3. Feature Engineering#
Convert categorical Season into numerical features:
Normalize ad spend (optional but helps training):
⚙️ Step 4. Split Data#
Time to create our train-test split — because life is all about testing your assumptions.
🧠 Step 5. Train the Model#
Let’s start simple — just a Linear Regression:
Check the coefficients (aka “how much each feature drives sales”):
📈 Translation: For every $1 increase in TV spend, sales increase by X units (if your CFO is reading this, round the number dramatically). 😅
📉 Step 6. Evaluate Performance#
✅ Interpretation:
MAE = average error in prediction
RMSE = punishes big mistakes more
R² = model’s bragging rights (1.0 = perfection, 0.0 = chaos)
📊 Step 7. Visualize Predictions#
Let’s make the boss happy with a plot that looks “AI-powered.” 🤖
🎨 If points hug the orange line → your model is doing great!
💬 Step 8. Business Insights#
Feature |
Effect |
Business Advice |
|---|---|---|
TV_Spend |
+ve |
Ads still work! Old-school isn’t dead 📺 |
Social_Media_Spend |
+ve |
Keep feeding the algorithm 💰 |
Discount_Percent |
-ve (sometimes) |
Too many discounts hurt profit margin 💸 |
Season_Summer |
+ve |
Ice creams sell better in heat 😎 |
💡 “A regression model is just a data-driven way to say ‘I told you so’ in a meeting.”
📈 Step 9. Bonus: Predict Future Sales#
You can predict next month’s sales like a forecasting wizard:
Now go make that dashboard and act mysterious when someone asks,
“So… how does it work?” 😏
💡 Optional Extension#
Try the same task using:
Ridge or Lasso Regression
PolynomialFeatures
or even a Random Forest (coming soon in later chapters 🌲)
Then compare R² — because competition keeps models humble.
🧩 Practice Exercises#
Challenge |
Hint |
|---|---|
1️⃣ Train a Ridge Regression model and compare its R² |
|
2️⃣ Add a new feature |
Think creatively! |
3️⃣ Create a seaborn plot of coefficients |
Use |
4️⃣ Try predicting sales when |
Does the model behave logically? |
5️⃣ Deploy your model to Colab and make it interactive |
Add widgets or sliders! |
🧠 Recap#
You loaded, cleaned, and prepped real data
Built a regression model
Evaluated business KPIs with metrics
Made it explainable and visually appealing
You’re now a certified Sales Forecast Whisperer 📊🧙♂️
🐍 Python Help#
If you’re unsure about any pandas or sklearn syntax, 🪄 explore Programming for Business — it’s your friendly guide to all the Python basics behind the magic!
🚀 Next Up#
➡️ Chapter 6: Classification Models Because predicting “how much” is cool — but predicting “who buys” is where real marketing power begins. 🎯
# Your code here