| name | edhec-corr-heatmap |
| description | Produce a publication-ready correlation heatmap (PDF+PNG) from a CSV or in-memory dataframe. Triggers when the user asks for "correlation heatmap", "corr matrix figure", or uploads a *.csv with numeric columns and asks for a heatmap. |
| args | {"input":"path to CSV or name of in-memory dataframe","output":"optional stem for the figure (default figures/corr_heatmap) -- writes <stem>.pdf and <stem>.png","method":"pearson | spearman | kendall (default pearson)"} |
Correlation heatmap
A four-phase skill. Each phase ends with a checkpoint the user can interrupt.
Phase 1 -- discover
Read the input. Identify numeric columns. For each column report:
- N non-missing
- % missing
- dtype
Stop and surface anything with > 5% missing, constant values (zero variance),
or non-numeric dtype that survived coercion. Note that pairwise-complete
observations are used by default (the pandas.corr default).
Phase 2 -- propose
Print:
- Final column list (after dropping all-NaN, constant, and non-numeric columns)
- Correlation method (default
pearson)
- Output stem (default
figures/corr_heatmap)
If the proposed matrix would have > 15 columns, stop and ask for confirmation.
Phase 3 -- compute
Compute the correlation matrix. Use:
df.corr(method=method, numeric_only=True)
- Strict upper-triangle mask via
np.triu(np.ones_like(corr, dtype=bool), k=1)
so the diagonal is hidden too
- Round annotations to 2 decimals
Phase 4 -- write
Emit a heatmap figure:
seaborn.heatmap(corr, mask=mask, annot=True, fmt=".2f", cmap="RdBu_r", vmin=-1, vmax=1, square=True, cbar_kws={"shrink": 0.7})
plt.tight_layout()
- Save both
<stem>.pdf (vector, for LaTeX) and <stem>.png (dpi=200, for previews)
- Default stem:
figures/corr_heatmap
- Print both paths; do not commit unless asked