Dự án phân tích hành vi khách hàng E-commerce sử dụng dataset Online Retail từ Kaggle/UCI với RFM Analysis, Cohort Analysis và triển khai trên Excel & Power BI.
- Tạo cơ sở dữ liệu PostgreSQL với các bảng customers, transactions, products
- Thực hiện phân tích RFM (Recency, Frequency, Monetary) để phân khúc khách hàng
- Thực hiện Cohort Analysis để phân tích retention rate
- Tạo các visualizations và heatmaps để hiển thị insights
- Triển khai Excel dashboards với charts và pivot tables
- Triển khai Power BI interactive dashboards với advanced analytics
E-commerce Customer Behavior/
├── data/
│ ├── raw/ # Dữ liệu gốc từ Kaggle
│ ├── processed/ # Dữ liệu đã xử lý (Excel files)
│ └── powerbi/ # Dữ liệu tối ưu cho Power BI
├── sql/
│ ├── create_tables.sql # Script tạo bảng
│ ├── rfm_analysis.sql # Query RFM Analysis
│ └── cohort_analysis.sql # Query Cohort Analysis
├── notebooks/
│ ├── data_preprocessing.ipynb # Tiền xử lý dữ liệu
│ ├── rfm_analysis.ipynb # Phân tích RFM
│ └── cohort_analysis.ipynb # Phân tích Cohort
├── scripts/
│ ├── create_excel_analysis.py # Tạo Excel basic analysis
│ ├── create_advanced_excel.py # Tạo Excel advanced metrics
│ ├── create_excel_dashboard.py # Tạo Excel với charts
│ └── create_powerbi_export.py # Xuất dữ liệu cho Power BI
├── docs/
│ ├── Excel_Analysis_Guide.md # Hướng dẫn phân tích Excel
│ ├── PowerBI_Implementation_Guide.md # Hướng dẫn triển khai Power BI
│ └── PowerBI_DAX_Measures.md # Template DAX measures
├── src/
│ └── utils/
│ └── db_connection.py # Class kết nối database
├── docker/
│ └── docker-compose.yml # Docker setup cho PostgreSQL
├── open_excel_analysis.bat # Quick launcher cho Excel
├── open_powerbi_setup.bat # Quick launcher cho Power BI
└── requirements.txt # Python dependencies
-
Clone repository và cài đặt dependencies:
pip install -r requirements.txt
-
Khởi động PostgreSQL với Docker:
cd docker docker-compose up -d -
Tải dataset:
- Tải file
online_retail.csvtừ Kaggle - Đặt vào thư mục
data/raw/
- Tải file
-
Data Preprocessing:
- Mở
notebooks/data_preprocessing.ipynb - Chạy từng cell để load, clean và import dữ liệu vào PostgreSQL
- Mở
-
RFM Analysis:
- Mở
notebooks/rfm_analysis.ipynb - Thực hiện phân khúc khách hàng dựa trên RFM scores
- Mở
-
Cohort Analysis:
- Mở
notebooks/cohort_analysis.ipynb - Phân tích retention rate theo cohorts
- Mở
-
Tạo Excel Analysis Files:
# Tạo 3 loại Excel files python scripts/create_excel_analysis.py # Basic analysis python scripts/create_advanced_excel.py # Advanced metrics python scripts/create_excel_dashboard.py # Interactive dashboard
-
Mở Excel Analysis:
- Double-click
open_excel_analysis.bat - Chọn loại file Excel muốn mở (Basic/Advanced/Dashboard)
- Double-click
-
Chuẩn bị dữ liệu cho Power BI:
python scripts/create_powerbi_export.py
-
Thiết lập Power BI:
- Double-click
open_powerbi_setup.bat - Import CSV files từ
data/powerbi/folder - Tham khảo
docs/PowerBI_Implementation_Guide.mdđể setup dashboard
- Double-click
- Database: PostgreSQL (Docker)
- Python Libraries:
- pandas, numpy (Data manipulation)
- matplotlib, seaborn, plotly (Visualization)
- psycopg2, sqlalchemy (Database connection)
- jupyter (Notebooks)
- xlsxwriter, openpyxl (Excel export)
- Business Intelligence:
- Microsoft Excel (Charts, Pivot Tables, Dashboards)
- Microsoft Power BI (Interactive dashboards, DAX measures)
- RFM Analysis: 11 customer segments với detailed insights
- Cohort Analysis: Retention heatmaps và performance metrics
- Visualizations: 3D plots, heatmaps, interactive charts
-
3 Excel Files:
online_retail_analysis.xlsx- Basic analysis với 8 sheetsonline_retail_advanced_analysis.xlsx- Advanced metrics & growth ratesonline_retail_dashboard.xlsx- Interactive charts & formatted dashboards
-
Excel Features:
- Executive dashboard với KPIs
- Customer segmentation với RFM scores
- Product ABC classification
- Geographic performance analysis
- Monthly trend analysis với growth rates
- Ready-to-use Pivot Tables và Charts
-
7 Optimized CSV Files:
sales_data.csv- Main fact table (397K records)customers.csv- Customer dimension (4.3K records)products.csv- Product dimension với ABC classificationcountries.csv- Geographic dimensiondate_dimension.csv- Complete date dimensionrfm_analysis.csv- Customer segmentationmonthly_summary.csv- Pre-aggregated metrics
-
Power BI Components:
- Complete DAX measures template
- Data model relationships guide
- 4 Main dashboard views (Executive, Customer, Product, Geographic)
- Advanced analytics với time intelligence
- Mobile-optimized layouts
Customer Segment Distribution:
- Champions: 110 customers (2.54%) - Top performers
- Loyal Customers: 363 customers (8.37%) - Consistent buyers
- Potential Loyalists: 799 customers (18.42%) - Growth opportunity
- At Risk: 297 customers (6.85%) - Need attention
- Lost: 1,733 customers (39.95%) - Win-back campaigns
Average Retention Rates:
- Month 1: 85.2%
- Month 3: 45.8%
- Month 6: 28.3%
- Month 12: 18.7%
Business KPIs:
- Total Revenue: $8.9M
- Total Customers: 4,338
- Average Order Value: $22.74
- Customer Lifetime Value: $2,048.69
- Active Markets: 37 countries
- PostgreSQL: localhost:5432
- Database: ecommerce_db
- Username: admin
- Password: password123
- pgAdmin: http://localhost:8080
- Excel Analysis:
docs/Excel_Analysis_Guide.md - Power BI Setup:
docs/PowerBI_Implementation_Guide.md - DAX Measures:
docs/PowerBI_DAX_Measures.md
- SQL: JOIN, Aggregation, Window functions, CTEs
- Customer Analytics: RFM modeling, Cohort analysis, Customer segmentation
- Data Visualization: Heatmaps, interactive plots, business dashboards
- Business Intelligence: Excel advanced features, Power BI development
- Database Management: PostgreSQL, Docker
- Programming: Python data analysis, automation scripts
- Đảm bảo Docker đã được cài đặt và chạy
- Dataset gốc có khoảng 500K+ records
- Excel files được tối ưu cho performance (sample data)
- Power BI files hỗ trợ real-time refresh
- Tất cả visualizations và analysis được document đầy đủ
Mọi đóng góp và cải thiện đều được chào đón! Vui lòng tạo issue hoặc pull request.
Nguồn dữ liệu: Online Retail Dataset - Kaggle
- Phân khúc khách hàng thành 11 nhóm (Champions, Loyal Customers, At Risk, etc.)
- Visualizations: 3D scatter plots, heatmaps, segment distribution
- Insights và recommendations cho từng segment
- Retention heatmap theo tháng
- Retention curves và performance comparison
- Insights về customer lifetime và churn patterns
- SQL: JOIN, Aggregation, Window functions, CTEs
- Customer Analytics: RFM modeling, Cohort analysis
- Data Visualization: Heatmaps, interactive plots
- Database Management: PostgreSQL, Docker
Customer Segment Summary:
- Champions: 500 customers (15.2%)
- Loyal Customers: 800 customers (24.3%)
- At Risk: 300 customers (9.1%)
...
Average Retention Rates:
- Month 1: 85.2%
- Month 3: 45.8%
- Month 6: 28.3%
- Month 12: 18.7%
- PostgreSQL: localhost:5432
- Database: ecommerce_db
- Username: admin
- Password: password123
- pgAdmin: http://localhost:8080
- Đảm bảo Docker đã được cài đặt và chạy
- Dataset gốc có khoảng 500K+ records
- Thời gian xử lý có thể mất vài phút cho large datasets
- Tất cả visualizations được lưu trong notebooks
Mọi đóng góp và cải thiện đều được chào đón! Vui lòng tạo issue hoặc pull request.
Nguồn dữ liệu: Online Retail Dataset - Kaggle