Black Friday Sales Prediction

I built this project to answer a deceptively simple question: can we predict how much a customer will spend on Black Friday using only their demographics and product categories — and then turn the model’s behavior into marketing decisions that make sense to humans?


Goal

The target is the purchase amount, and the input space is classic “high-cardinality retail”: product categories, city labels, and demographic buckets. The objective was not just to get a low error number, but to learn what actually drives spending — so the final output reads like a story: what matters, what barely matters, and where a business should focus attention.

Data cleaning + EDA

Before modeling, I handled missing category fields, standardized categorical encoding, and sanity-checked the target distribution. Two quick plots changed how I thought about the problem: the purchase distribution makes it clear this is a heavy-tailed target, and the explained-variance view shows that product categories dominate what can be “explained” at all.

Purchase distribution

Purchases are strongly right-skewed with a heavy tail — extreme spenders matter, and “normal error” assumptions are fragile.

Explained variance by feature (eta squared)

Most explainable variance comes from Product_Category_1 (and then Product_Category_2); demographics are weaker alone.

The business-facing signals are surprisingly crisp. The volume is dominated by males aged 26–35, so even small conversion improvements there move revenue materially. City B wins on transaction count while City C wins on average purchase, which suggests a “volume vs value” split strategy. New residents show a distinct spending pattern that can be used for segmentation, while marital status barely moves the needle — a useful reminder that not every demographic field is worth building campaigns around.


Modeling

I trained linear baselines (Linear, Ridge, Huber) and non-linear models (Decision Tree, Random Forest, XGBoost, CatBoost), evaluating with RMSE and R² on a held-out test split. The pattern is the point: linear models underfit because spending behavior is interaction-heavy, while tree ensembles win by learning non-linearities and feature interactions without hand-crafted feature engineering.

Model comparison (RMSE)

RMSE ranking makes the story obvious: ensembles cluster near the top; linear baselines lag behind.

What I like here is how “modern tabular ML” behaves when the data has a few dominant categorical drivers: multiple strong tree-based models end up with similar performance because they’re all capturing the same underlying structure; after that, improvements tend to be about optimization details, not a totally different understanding of the data. :contentReference[oaicite:3]{index=3}

Hyperparameter tuning

I ran a randomized hyperparameter search for XGBoost and refit the best configuration. The tuned model improves only marginally, which is statistically honest and also useful: it suggests the ceiling is more “feature-limited” than “tuning-limited.”

XGBoost baseline vs tuned
Learning rate vs estimators tradeoff

Two reasons this outcome makes sense: first, the dataset’s predictive signal is dominated by a few strong categorical drivers, so once the model is in the right regime, hyperparameters only fine-tune around that signal. Second, beyond a point, gains are often within split-to-split variability; the next real jump usually comes from new features or a different target treatment rather than squeezing the last drop out of tuning. :contentReference[oaicite:4]{index=4}


Closing thought

I like this project for a personal reason: I always wondered who really shops on Black Friday, because the “deals” don’t always feel that cheap. I expected one story and the data told me another — especially around who spends more. That small moment of having my assumptions corrected is exactly why I enjoy data-informed work: it’s not just prediction, it’s a quiet fact-check on what we think we know.


Project Details

Author: Sajal Gupta

Year: 2024

Category: DS/ML

Tech: Python, Pandas, NumPy, scikit-learn, XGBoost, Random Forest, Matplotlib

Focus: High-cardinality tabular regression, model comparison (linear vs ensembles), interpretable insights for business segmentation, and disciplined tuning/diagnostics.

 View Source Code