146 lines
5.3 KiB
Markdown
146 lines
5.3 KiB
Markdown
**Source of truth** : https://git.gregoiremureau.com/openclassroom-ai/oc-p05-customer-segmentation
|
|
|
|
```bash
|
|
git clone https://git.gregoiremureau.com/openclassroom-ai/oc-p05-customer-segmentation.git
|
|
git clone https://git.gregoiremureau.com/openclassroom-ai/oc-p05-customer-segmentation.git
|
|
```
|
|
|
|
Dataset: see `fetch-data.sh` (excluded from git if large).
|
|
|
|
# Customer Segmentation Project - Olist
|
|
|
|
📘 Ce projet est également disponible en [français 🇫🇷](./README.fr.md)
|
|
|
|
## 📋 Project Context
|
|
|
|
This project was carried out as part of a consulting assignment for **Olist**, a Brazilian company offering an online marketplace sales solution. The main objective is to support Olist in setting up their Data team and delivering their first Data Science use case around customer segmentation.
|
|
|
|
## 🎯 Objectives
|
|
|
|
The project is divided into two main missions:
|
|
|
|
1. **SQL Mission**: Develop SQL queries to feed the team's Customer Experience dashboard
|
|
2. **Segmentation Mission**: Create an actionable customer segmentation for the Marketing team, based on unsupervised clustering algorithms
|
|
|
|
## 📊 Data
|
|
|
|
The data used comes from an anonymized database provided by Olist, containing:
|
|
- Order history since January 2017
|
|
- Information on purchased products
|
|
- Customer satisfaction reviews
|
|
- Customer location
|
|
- Seller data
|
|
|
|
**⚠️ Important note**: The database is not included in this repository due to its size. It can be downloaded at the following address:
|
|
- **URL**: https://course.oc-static.com/projects/olist.db
|
|
|
|
## 📁 Project Structure
|
|
|
|
```
|
|
├── P5_01_script_052025.sql
|
|
├── P5_02_notebook_exploration_052025.ipynb
|
|
├── P5_03_notebook_essais_052025.ipynb
|
|
├── P5_04_notebook_simulation_052025.ipynb
|
|
└── P5_05_presentation_052025.pptx
|
|
```
|
|
|
|
### 1. `P5_01_script_052025.sql`
|
|
|
|
**SQL script for the Customer Experience Dashboard**
|
|
|
|
This file contains 4 essential SQL queries to feed the customer service dashboard:
|
|
|
|
1. **Late orders**: Identification of recent orders (less than 3 months) received with at least 3 days of delay (excluding cancelled orders)
|
|
|
|
2. **Top sellers by revenue**: List of sellers who generated revenue above 100,000 Real on delivered orders
|
|
|
|
3. **High-performing new sellers**: Identification of recent sellers (less than 3 months of tenure) who have already sold more than 30 products
|
|
|
|
4. **Problematic geographic areas**: The 5 postal codes with more than 30 reviews and the worst average satisfaction scores over the last 12 months
|
|
|
|
### 2. `P5_02_notebook_exploration_052025.ipynb`
|
|
|
|
**Exploration and feature engineering notebook**
|
|
|
|
This notebook contains:
|
|
- Exploratory data analysis (EDA)
|
|
- Creation and transformation of customer features
|
|
- Implementation of the RFM method (Recency, Frequency, Monetary)
|
|
- Data preprocessing (normalization, encoding)
|
|
- Initial visualizations and insights on customer behavior
|
|
|
|
### 3. `P5_03_notebook_essais_052025.ipynb`
|
|
|
|
**Modeling and clustering notebook**
|
|
|
|
This notebook presents:
|
|
- The different clustering approaches tested (K-means, DBSCAN, etc.)
|
|
- Optimization of the number of clusters (elbow method, silhouette score)
|
|
- Evaluation of model performance
|
|
- Detailed characterization of each customer segment
|
|
- Business validation of the identified segments
|
|
|
|
### 4. `P5_04_notebook_simulation_052025.ipynb`
|
|
|
|
**Simulation notebook for the maintenance contract**
|
|
|
|
This notebook analyzes:
|
|
- Cluster stability over time
|
|
- Evolution of the Adjusted Rand Index (ARI) across different periods
|
|
- Temporal distribution of features
|
|
- Recommendations on the update frequency of the segmentation model
|
|
- Kolmogorov-Smirnov tests to detect drifts
|
|
|
|
### 5. `P5_05_presentation_052025.pptx`
|
|
|
|
**Results presentation**
|
|
|
|
This presentation summarizes:
|
|
- The methodological approach adopted
|
|
- The customer segments identified and their characteristics
|
|
- Actionable insights for the Marketing team
|
|
- Recommendations on the maintenance contract
|
|
- Improvement perspectives
|
|
|
|
## 🛠️ Technologies Used
|
|
|
|
- **SQL**: Database querying
|
|
- **Python**: Data analysis and machine learning
|
|
- pandas, numpy: data manipulation
|
|
- scikit-learn: clustering algorithms
|
|
- matplotlib, seaborn: visualization
|
|
- yellowbrick: cluster evaluation
|
|
- **Jupyter Notebook**: development and documentation
|
|
|
|
## 📈 Methodology
|
|
|
|
1. **Exploratory analysis**: In-depth understanding of the data and customer behavior
|
|
2. **Feature engineering**: Creation of relevant variables (RFM and other behavioral metrics)
|
|
3. **Modeling**: Testing and selection of clustering algorithms
|
|
4. **Evaluation**: Technical validation (silhouette, ARI) and business validation of segments
|
|
5. **Simulation**: Temporal stability analysis to define maintenance frequency
|
|
|
|
## 📝 Deliverables
|
|
|
|
- ✅ SQL script with 4 queries for the dashboard
|
|
- ✅ Exploration and feature engineering notebook
|
|
- ✅ Modeling notebook with different clustering trials
|
|
- ✅ Simulation notebook for the maintenance contract
|
|
- ✅ Segmentation presentation and recommendations
|
|
|
|
## 🎓 Skills Developed
|
|
|
|
- Advanced SQL querying with aggregations and joins
|
|
- Unsupervised learning (clustering)
|
|
- Business-oriented feature engineering
|
|
- Evaluation of model quality and stability
|
|
- Communication of results to business teams
|
|
|
|
## 👤 Author
|
|
|
|
**Grégoire Mureau**
|
|
Completion date: May 2025
|
|
|
|
---
|
|
|
|
*This project was carried out as part of OpenClassrooms' AI Engineer program*
|