You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Normalized" mutual information divides nats by bits and drifts with sample size #212
compute_predictor_correlations documents a "normalized mutual information matrix" that is "comparable to correlation coefficients" (predictor_analysis.py:72), and hardcodes the diagonal to 1.0 (:154-155). The values are not normalized: mutual information in nats is divided by an entropy in bits, and for a continuous column that entropy is a plug-in discrete estimate that reduces to log2(n_distinct) — a measure of sample size, not information.
Reproduction
Two identical columns, where the correct normalized value is exactly 1.0:
Perfectly dependent variables score around 0.55, and the value drifts upward with sample size. At n=1000: MI is 5.651 nats while _compute_entropy returns 9.9658 bits, which is exactly log2(1000).
Two errors compound. Dividing by H·ln2 to fix the units gives 0.818, still not 1.0, because the log2(n_distinct) proxy is not the entropy of a continuous variable. Because genuinely categorical columns get a real entropy while continuous ones get log2(n), values are not comparable across variable types — and predictor_target_mi (:221-225) is used to rank predictors for imputation.
_compute_mutual_information at :529-550 — sklearn, returns nats
_compute_entropy at :553-568 — log2, returns bits
Suggested fix
Convert units consistently, and use a normaliser valid for continuous variables — a proper NMI estimator, or normalising by min(H(X), H(Y)) computed on the same discretisation used for the MI estimate. Failing that, drop the normalisation, document the units as raw nats, and stop hardcoding the diagonal to 1.0, which currently hides the defect from inspection.
Found during a pre-JOSS-submission audit (#201), reproduced independently by a second reviewer.
Activity