Retail/Fashion EDA Framework
Comprehensive EDA approach for retail/fashion/tabular data, validated through Walmart, H&M, and 7+ fashion-lifecycle-pricing competitions.
Problem
Most ML projects skip EDA or do it superficially (just df.describe() + a histogram).
This leads to:
- Missing data issues discovered too late
- Train/test distribution shift not caught
- High-cardinality features used as raw categoricals (overfit)
- Text features not extracted from product descriptions
- Time-based leakage in train/test split
- Hierarchical structure ignored (e.g., 5-level category hierarchy in H&M)
Real case (validated 2026-06-02 on H&M articles.csv):
- 105,542 rows × 25 cols
- Only 416 missing values (0.39% in
detail_desc)
- 5-level hierarchical structure: index_group → section → department → product_type → product_group
- 45,875 unique
prod_name (high cardinality)
- 43,404 unique
detail_desc (text, 142 chars avg)
Without proper EDA, none of these are caught before feature engineering.
The 5-Stage EDA Pipeline
Stage 1: Data Quality Audit (FIRST)
Tools: ydata-profiling (13.5k★), missingno (4.2k★)
# Quick data quality report
import ydata_profiling
profile = ydata_profiling.ProfileReport(df, title="Data Quality Report")
profile.to_file("eda/data_quality.html")
# Missing data visualization
import missingno as msno
msno.matrix(df) # Bar chart of missing per column
msno.heatmap(df) # Correlation of missingness between columns
msno.dendrogram(df) # Hierarchical clustering of missingness
Look for:
- Missing value patterns (random vs systematic)
- High-cardinality categoricals (will overfit tree models)
- Skewed numerical features (need log transform)
- Constant/quasi-constant features (drop immediately)
- Duplicate rows
- Outliers (use IQR or z-score, not just visual)
Stage 2: Statistical Profiling (Train vs Test)
Tools: sweetviz (3.1k★)
# Compare train vs test
import sweetviz as sv
report = sv.compare([train_df, "Train"], [test_df, "Test"], target_feat="target")
report.show_html("eda/train_vs_test.html")
Look for:
- Train/test distribution shift
- Per-segment behavior differences
- Data leakage (test features in train)
- Time-based trends (if applicable)
Stage 3: Domain-Specific EDA
For retail/fashion, focus on:
| Pattern |
Tools |
What to look for |
| Customer segmentation |
RFM analysis |
Recency, Frequency, Monetary quintiles |
| Transaction patterns |
pandas, seaborn |
Basket size, frequency, time-of-day, day-of-week |
| Article co-occurrence |
custom ItemCF |
Items bought together, substitute/companion |
| Fashion seasonality |
statsmodels, tslumen |
Year-over-year, holiday effects |
| Cold start analysis |
pandas |
% test customers with no history, % new articles |
| Inventory/availability |
groupby, time series |
Stockouts, restock patterns |
Stage 4: Time-Series EDA (if applicable)
Tools: tslumen (72★, HSBC-maintained), statsmodels
# For sales forecasting competitions
import tslumen
tslumen.from_ts(df.set_index('date')['sales']).plot()
# Decomposition, ACF/PACF, stationarity tests
Look for:
- Trend / seasonality / residual decomposition
- Stationarity (ADF test)
- Autocorrelation structure (ACF/PACF)
- Holiday/special-event effects
- Data frequency consistency (missing weeks, etc.)
Stage 5: EDA Summary
Auto-generated eda/EDA_SUMMARY.md with:
- Files generated checklist
- Manual review items
- Next-step recommendations
Top EDA Library Recommendations (2026-06-02)
| Library |
Stars |
Use for |
Install |
ydata-profiling |
13.5k |
Comprehensive 1-line EDA report |
pip install ydata-profiling |
great_expectations |
11.5k |
Data quality + unit tests for data |
pip install great_expectations |
visidata |
9.1k |
Terminal-based interactive exploration |
pip install visidata |
lux |
5.4k |
Auto-viz on dataframe print |
pip install lux-api |
missingno |
4.2k |
Missing data visualization |
pip install missingno |
sweetviz |
3.1k |
Compare train vs test |
pip install sweetviz |
dataprep |
2.2k |
Low-code data prep + EDA |
pip install dataprep |
AutoViz |
1.9k |
1-line automatic viz |
pip install autoviz |
tslumen |
72 |
Time-series specific EDA |
pip install tslumen |
| RFM analysis |
41 |
Customer segmentation |
pip install rfm-analysis |
Common EDA Mistakes (Anti-Patterns)
- ❌ Skipping EDA to save time → always leads to feature engineering errors
- ❌ Only looking at summary statistics → miss distribution shape
- ❌ Ignoring train/test distribution shift → catastrophic in production
- ❌ Not checking missingness correlation → indicates systematic missingness
- ❌ Assuming all categorical = independent → categories may be related
- ❌ Forgetting to check time-based leakage → future data in training
- ❌ Not visualizing outliers → they may be valid (e.g., luxury items)
- ❌ Treating all features equally → ID-like features need special handling
Real Case: H&M Personalized Fashion Recommendations
Data: articles.csv (105,542 rows × 25 cols)
Date: 2026-06-02
EDA Findings
- Data Quality: Only 416 missing (0.39% in
detail_desc) — extremely clean
- Hierarchical structure: 5 levels (index_group → section → department → product_type → product_group)
index_group_name (5 unique): Ladieswear, Menswear, Baby/Children, Sport, Divided
department_name (250 unique)
product_type_name (131 unique)
- Top product types: Trousers (11K), Dress (10K), Sweater (9K)
- Top colors: Black (22K), Blue (18K), White (12K) — top 5 = 67% of articles
- Text features:
prod_name 45,875 unique, detail_desc 43,404 unique (mean 142 chars)
- Data quality issues:
- Some numerical cols have
-1 values (treat as NaN)
article_id is large numeric (use as index only, not as feature)
Recommendations for Feature Engineering
- Hierarchy-based target encoding — 5 levels perfect for tree models
- Text features from
detail_desc — 142 chars avg, ideal for embeddings
- Color groupings — reduce 50 colors to 10-15 effective groups
- Product variant detection —
product_code shared across variants
- Time-aware features — article age, recent sales velocity, seasonality
How to Apply
Option 1: Use the existing pipeline (recommended)
The ml-agent-code-template includes a pre-built EDA pipeline:
# Install dependencies
pip install ydata-profiling missingno sweetviz
# Run the pipeline
bash ml-agent-code-template/.claude/hooks/eda_pipeline.sh <data.csv>
# With optional flags
bash ml-agent-code-template/.claude/hooks/eda_pipeline.sh <data.csv> \
--segment=customer_type --time-series=date
Option 2: Manual invocation
import ydata_profiling
import missingno as msno
import sweetviz as sv
# Stage 1
profile = ydata_profiling.ProfileReport(df, title="Data Quality Report", minimal=True)
profile.to_file("eda/data_quality.html")
# Stage 2
report = sv.compare([train, "Train"], [test, "Test"], target_feat="target")
report.show_html("eda/train_vs_test.html")
Related Skills
adversarial-validation-kaggle — for distribution shift detection
kaggle-data-format-first — for understanding schema
kaggle-top-performer-replication — for 1st place feature analysis
Empirical Evidence
MLE-Bench experiments:
- Spaceship Titanic Gold: 0.8506 — EDA revealed
Cabin split into deck/side/num was key
- Jigsaw Toxic Gold: 0.98829 — EDA on per-label distribution identified imbalance
- TPS May Silver: 0.99754 — EDA on f_27 string structure drove feature breakthrough
fashion-lifecycle-pricing:
- H&M R27 (best, Priv 0.02314): 27 experiments preceded by proper EDA
- Walmart R08 (best, LB=2720): EDA on MarkDown missing patterns + seasonality
1---2name: retail-eda-framework3description: Comprehensive EDA approach for retail/fashion/tabular ML using best-in-class libraries. Use during stage 1 (data understanding) of any ML pipeline. Built around 5-stage pipeline: (1) data quality with ydata-profiling + missingno, (2) statistical profiling with sweetviz, (3) domain-specific (RFM, transaction patterns, co-occurrence), (4) time-series with tslumen, (5) summary. Validated on H&M Personalized Fashion Recommendations (105K articles, 25 cols, 0.39% missing — extremely clean).4---56# Retail/Fashion EDA Framework78> Comprehensive EDA approach for retail/fashion/tabular data, validated through Walmart, H&M, and 7+ fashion-lifecycle-pricing competitions.910## Problem1112Most ML projects skip EDA or do it superficially (just `df.describe()` + a histogram).13This leads to:14- Missing data issues discovered too late15- Train/test distribution shift not caught16- High-cardinality features used as raw categoricals (overfit)17- Text features not extracted from product descriptions18- Time-based leakage in train/test split19- Hierarchical structure ignored (e.g., 5-level category hierarchy in H&M)2021**Real case (validated 2026-06-02 on H&M articles.csv)**:22- 105,542 rows × 25 cols23- Only 416 missing values (0.39% in `detail_desc`)24- 5-level hierarchical structure: index_group → section → department → product_type → product_group25- 45,875 unique `prod_name` (high cardinality)26- 43,404 unique `detail_desc` (text, 142 chars avg)2728Without proper EDA, none of these are caught before feature engineering.2930## The 5-Stage EDA Pipeline3132### Stage 1: Data Quality Audit (FIRST)3334**Tools**: `ydata-profiling` (13.5k★), `missingno` (4.2k★)3536```python37# Quick data quality report38import ydata_profiling39profile = ydata_profiling.ProfileReport(df, title="Data Quality Report")40profile.to_file("eda/data_quality.html")4142# Missing data visualization43import missingno as msno44msno.matrix(df) # Bar chart of missing per column45msno.heatmap(df) # Correlation of missingness between columns46msno.dendrogram(df) # Hierarchical clustering of missingness47```4849**Look for**:50- Missing value patterns (random vs systematic)51- High-cardinality categoricals (will overfit tree models)52- Skewed numerical features (need log transform)53- Constant/quasi-constant features (drop immediately)54- Duplicate rows55- Outliers (use IQR or z-score, not just visual)5657### Stage 2: Statistical Profiling (Train vs Test)5859**Tools**: `sweetviz` (3.1k★)6061```python62# Compare train vs test63import sweetviz as sv64report = sv.compare([train_df, "Train"], [test_df, "Test"], target_feat="target")65report.show_html("eda/train_vs_test.html")66```6768**Look for**:69- Train/test distribution shift70- Per-segment behavior differences71- Data leakage (test features in train)72- Time-based trends (if applicable)7374### Stage 3: Domain-Specific EDA7576For **retail/fashion**, focus on:7778| Pattern | Tools | What to look for |79|---------|-------|-------------------|80| **Customer segmentation** | RFM analysis | Recency, Frequency, Monetary quintiles |81| **Transaction patterns** | pandas, seaborn | Basket size, frequency, time-of-day, day-of-week |82| **Article co-occurrence** | custom ItemCF | Items bought together, substitute/companion |83| **Fashion seasonality** | statsmodels, tslumen | Year-over-year, holiday effects |84| **Cold start analysis** | pandas | % test customers with no history, % new articles |85| **Inventory/availability** | groupby, time series | Stockouts, restock patterns |8687### Stage 4: Time-Series EDA (if applicable)8889**Tools**: `tslumen` (72★, HSBC-maintained), `statsmodels`9091```python92# For sales forecasting competitions93import tslumen94tslumen.from_ts(df.set_index('date')['sales']).plot()95# Decomposition, ACF/PACF, stationarity tests96```9798**Look for**:99- Trend / seasonality / residual decomposition100- Stationarity (ADF test)101- Autocorrelation structure (ACF/PACF)102- Holiday/special-event effects103- Data frequency consistency (missing weeks, etc.)104105### Stage 5: EDA Summary106107Auto-generated `eda/EDA_SUMMARY.md` with:108- Files generated checklist109- Manual review items110- Next-step recommendations111112## Top EDA Library Recommendations (2026-06-02)113114| Library | Stars | Use for | Install |115|---------|------|---------|---------|116| `ydata-profiling` | 13.5k | Comprehensive 1-line EDA report | `pip install ydata-profiling` |117| `great_expectations` | 11.5k | Data quality + unit tests for data | `pip install great_expectations` |118| `visidata` | 9.1k | Terminal-based interactive exploration | `pip install visidata` |119| `lux` | 5.4k | Auto-viz on dataframe print | `pip install lux-api` |120| `missingno` | 4.2k | Missing data visualization | `pip install missingno` |121| `sweetviz` | 3.1k | Compare train vs test | `pip install sweetviz` |122| `dataprep` | 2.2k | Low-code data prep + EDA | `pip install dataprep` |123| `AutoViz` | 1.9k | 1-line automatic viz | `pip install autoviz` |124| `tslumen` | 72 | Time-series specific EDA | `pip install tslumen` |125| RFM analysis | 41 | Customer segmentation | `pip install rfm-analysis` |126127## Common EDA Mistakes (Anti-Patterns)1281291. ❌ **Skipping EDA** to save time → always leads to feature engineering errors1302. ❌ **Only looking at summary statistics** → miss distribution shape1313. ❌ **Ignoring train/test distribution shift** → catastrophic in production1324. ❌ **Not checking missingness correlation** → indicates systematic missingness1335. ❌ **Assuming all categorical = independent** → categories may be related1346. ❌ **Forgetting to check time-based leakage** → future data in training1357. ❌ **Not visualizing outliers** → they may be valid (e.g., luxury items)1368. ❌ **Treating all features equally** → ID-like features need special handling137138## Real Case: H&M Personalized Fashion Recommendations139140**Data**: `articles.csv` (105,542 rows × 25 cols)141**Date**: 2026-06-02142143### EDA Findings144- **Data Quality**: Only 416 missing (0.39% in `detail_desc`) — extremely clean145- **Hierarchical structure**: 5 levels (index_group → section → department → product_type → product_group)146 - `index_group_name` (5 unique): Ladieswear, Menswear, Baby/Children, Sport, Divided147 - `department_name` (250 unique)148 - `product_type_name` (131 unique)149- **Top product types**: Trousers (11K), Dress (10K), Sweater (9K)150- **Top colors**: Black (22K), Blue (18K), White (12K) — top 5 = 67% of articles151- **Text features**: `prod_name` 45,875 unique, `detail_desc` 43,404 unique (mean 142 chars)152- **Data quality issues**:153 - Some numerical cols have `-1` values (treat as NaN)154 - `article_id` is large numeric (use as index only, not as feature)155156### Recommendations for Feature Engineering1571. **Hierarchy-based target encoding** — 5 levels perfect for tree models1582. **Text features from `detail_desc`** — 142 chars avg, ideal for embeddings1593. **Color groupings** — reduce 50 colors to 10-15 effective groups1604. **Product variant detection** — `product_code` shared across variants1615. **Time-aware features** — article age, recent sales velocity, seasonality162163## How to Apply164165### Option 1: Use the existing pipeline (recommended)166167The `ml-agent-code-template` includes a pre-built EDA pipeline:168169```bash170# Install dependencies171pip install ydata-profiling missingno sweetviz172173# Run the pipeline174bash ml-agent-code-template/.claude/hooks/eda_pipeline.sh <data.csv>175176# With optional flags177bash ml-agent-code-template/.claude/hooks/eda_pipeline.sh <data.csv> \178 --segment=customer_type --time-series=date179```180181### Option 2: Manual invocation182183```python184import ydata_profiling185import missingno as msno186import sweetviz as sv187188# Stage 1189profile = ydata_profiling.ProfileReport(df, title="Data Quality Report", minimal=True)190profile.to_file("eda/data_quality.html")191192# Stage 2193report = sv.compare([train, "Train"], [test, "Test"], target_feat="target")194report.show_html("eda/train_vs_test.html")195```196197## Related Skills198199- `adversarial-validation-kaggle` — for distribution shift detection200- `kaggle-data-format-first` — for understanding schema201- `kaggle-top-performer-replication` — for 1st place feature analysis202203## Empirical Evidence204205**MLE-Bench experiments**:206- **Spaceship Titanic Gold**: 0.8506 — EDA revealed `Cabin` split into deck/side/num was key207- **Jigsaw Toxic Gold**: 0.98829 — EDA on per-label distribution identified imbalance208- **TPS May Silver**: 0.99754 — EDA on f_27 string structure drove feature breakthrough209210**fashion-lifecycle-pricing**:211- **H&M R27 (best, Priv 0.02314)**: 27 experiments preceded by proper EDA212- **Walmart R08 (best, LB=2720)**: EDA on MarkDown missing patterns + seasonality