Skip to content
SS
← Projects

Flagship · SQL · Power BI · Machine Learning

E-Commerce Customer Satisfaction & Predictive Analytics

Analyzed 99K e-commerce orders using SQL, finding that 1-star reviews had nearly twice the delivery time of 5-star reviews. Built an 8-table PostgreSQL pipeline processing 340K rows and a Power BI dashboard; prepared 126 model inputs, including engineered numerical features and encoded categorical variables, and evaluated Logistic Regression and Random Forest models on historical completed orders, achieving 50% recall for negative reviews.

PostgreSQLSQLPythonPandasscikit-learnPower BIDAX
99K
orders analyzed
340K
rows · 8 tables
126
prepared model inputs
50%
recall on bad reviews
Final Power BI report — KPI scorecard, delivery-vs-reviews chart, and revenue by category, state and time.

01

Business problem

Olist is a Brazilian e-commerce marketplace. The question: what drives revenue and customer satisfaction across Brazil — and which factors separate 1–2 star reviews from 5-star ones?

This is a historical predictive analysis of completed orders: it identifies the patterns behind past negative reviews. A real-time early-warning model would require inputs available at the time of prediction — see the limitations section.

02

Dataset & scope

Public Olist Brazilian E-Commerce dataset: ~99K orders and ~340K rows across 8 tables, September 2016 – September 2018. September 2018 is a partial month and is annotated on the trend chart rather than hidden.

Personal learning project on public data — not affiliated with Olist.

03

Data cleaning & validation

  • Loaded raw files into staging tables and fixed encoding, duplicate and orphan-record issues in SQL, with row-count checks and zero rows deleted.
  • Locked a single revenue definition — R$13,591,643.70, item price with freight excluded as pass-through — and verified every query and DAX measure against it.
  • For modeling: removed 446 duplicate order IDs, filled 1,273 missing categories, and dropped ambiguous 3-star reviews — leaving 87,946 orders.

04

SQL & database architecture

An 8-table PostgreSQL schema with composite keys and foreign-key constraints. Analysis used joins, CTEs, subqueries, aggregation and date functions.

Entity relationship diagram of the PostgreSQL schema.

05

Exploratory analysis

QuestionFinding
Revenue trendSteady month-over-month growth, peaking November 2017 (holiday shopping)
CategoriesHealth & beauty leads, but the top 5 categories are only ~40% of revenue
StatesSão Paulo alone is ~38% of revenue — 3x the #2 state
ConcentrationTop 5 states = 74% of revenue vs. top 5 categories = 40%
Delivery vs. reviews5-star orders arrive in ~10 days; 1-star orders take about twice as long

The strongest pattern is a clean staircase — as delivery time rises, review scores fall:

Review scoreAvg delivery daysOrders
5 stars10.257,066
4 stars11.818,987
3 stars13.87,961
2 stars16.22,941
1 star20.89,406

06

Dashboard & visualization

The report was planned on a blueprint before building in Power BI, then implemented with DAX measures (TOPN, DATEDIFF, DIVIDE), Power Query cleaning and a custom theme. A PowerPoint executive briefing accompanies it.

Layout blueprint used to plan the dashboard.

07

Machine learning methodology

  • SQL feature pull: one row per order with delivery timing, cost, category and location, plus a binary bad-review label (1–2 stars).
  • Prepared 126 model inputs, including engineered numerical features (such as a cross-state shipping proxy) and encoded categorical variables.
  • 80/20 stratified split (70,356 train / 17,590 test) preserving the 14% bad-review rate.
  • Trained a scaled, class-weighted Logistic Regression and a Random Forest on the identical split.
  • Some model inputs depend on actual delivery timing, so the model evaluates completed orders; a live early-warning version would need features knowable before delivery.
Phase 5 ML pipeline.

08

Model evaluation & limitations

ModelRecallPrecisionROC-AUC
Logistic Regression50%35%0.728
Random Forest35%51%0.731

Accuracy was deliberately not the target: with only 14% bad reviews, predicting "good" for every order scores 86% and catches nothing. Logistic Regression was chosen because, when the goal is catching negative reviews, a missed bad review costs more than a false alarm.

Limitations: ROC-AUC near 0.73 is moderate, and the selected model wrongly flags 2,317 good orders in the test set. Results are on historical public data and have not been tested in a live operation.

Random Forest feature importances — lateness vs. the promised date ranks #1.

09

Findings & recommendations

Customers react to broken promises, not clock time. Lateness against the estimated delivery date outranked raw delivery speed; three of the top five features are delivery timing, together about 40% of the model's decisions. Category and location barely registered.

How an e-commerce business could use this (proposed, not measured outcomes):

  • Set conservative delivery estimates that are reliably met, rather than aggressive ones that get missed.
  • Build a future early-warning model using only inputs available while an order is in transit, to flag high-risk orders for a proactive message, discount or shipping upgrade.
  • Treat dissatisfaction as a fulfillment execution problem — it is not concentrated in particular categories or regions.
  • Concentrate marketing geographically while keeping the product catalog broad.

10

Repository

SQL scripts, Python notebooks, the Power BI file, exports and the briefing deck are all on GitHub.

View repository on GitHub