feature-importance-financiallisted
Install: claude install-skill howard-lynn-ye/fin-skills
# Feature importance for financial data
**Three methods, three different lies, and the worst of them is the default.** Advances in
Financial Machine Learning (Lopez de Prado 2018), chapter 8. `feature_importances_` is one
attribute access away and it is in-sample, biased toward high-cardinality columns, and split
between features that substitute for each other. Permutation importance fixes the first two and
not the third. And every one of them is meaningless if the fold was shuffled.
Every number below is printed by `scripts/feature_importance.py` (numpy, seed 0, **23 s**,
`scikit-learn` optional — the script carries its own CART and bagged forest, so the claims hold
on a bare install and are *checked against* sklearn when it is present).
## 1. The design, so "wrong" is measurable
n = 1,500. `y = 1.00 * x0 + 0.60 * x2 + e`, where `e` is a rolling mean of 25 shocks — each row's
target is fully explained by its own features, and neighbouring rows share most of their
*residual*. That is what an overlapping label horizon does, and it is what makes section 5 happen.
| feature | distinct values | corr with x0 | corr with y | truth |
|---|---|---|---|---|
| **x0** | 1,500 | 1.000 | 0.425 | informative, coefficient 1.00 |
| **x1** | 1,500 | **0.995** | 0.426 | a noisy copy of x0 — **no independent information** |
| **x2** | 1,500 | 0.005 | 0.293 | informative, coefficient 0.60 |
| **x3** | **1,500** | 0.032 | 0.016 | **irrelevant**, continuous |
| **x4** | **2** | 0.007 | 0.011