Align brainscore pipeline with official Brain-Score (closes #9) - #10
Align brainscore pipeline with official Brain-Score (closes #9)#10c-mulliken wants to merge 2 commits into
Conversation
Addresses all substantive deviations from the official CrossRegressedCorrelation pipeline identified in #9, per the "hybrid" default policy (align low-risk defaults; keep ceiling normalization opt-in): - Ceiling normalization (opt-in, #1): --ceiling_normalize divides the score by the median per-neuroid noise ceiling. --ceiling_sb_correct applies Spearman-Brown to the reliability first. - Spearman-Brown helper (#4): add utils.brainscore.spearman_brown and a spearman_brown option on TVSD_TestDataset._compute_reliability so a recomputed reliability can serve as an SB-corrected ceiling. - Feature standardization now opt-in (#3): --standardize defaults off to match Brain-Score (PLS centers internally, scale=False). Replaces the always-on StandardScaler in the old default path. - CV aligned to Brain-Score (#5): default ShuffleSplit with n_splits=10, train_size=0.9; KFold kept via --cv_strategy kfold. - PCA leakage (#2): per-fold PCA is fit on the train fold only (leak-free); document that the generate-time IncrementalPCA path leaks and expose --skip_pca. Replaces the conflated --preprocessed flag with --standardize / --skip_pca. Updates scripts/benchmark.sh accordingly. Adds tests/test_brainscore.py and an SB reliability test; full suite 91 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Empirical inspection of THINGS_normMUA.mat showed `reliab` is mean pairwise
single-trial reliability (median ~0.37), `test_MUA` is exactly the 30-rep
average, and the true noise ceiling of that average is ~0.95. The old
within-train CV had no valid ceiling and the n=2 SB correction on single-trial
reliab was wrong. This implements the principled pipeline:
- brainscore.py: add score_train_test (fit on train, predict held-out test,
per-neuroid Pearson, median over neuroids; std via bootstrap over test
stimuli). Extract shared _fit_predict/_correlations/_reduce; compute_brain_score
(within-train CV) kept as a legacy path reusing them.
- benchmark.py: fit on train_MUA, score on test_MUA (mean of test_MUA_reps).
Neuron selection uses single-trial reliab (>0.3, per TVSD paper); ceiling is
the split-half+SB internal consistency from TVSD_TestDataset(recompute,
spearman_brown). Drop the incorrect --ceiling_sb_correct.
- generate_activations.py: --split {train,test}; save under TVSD_train / TVSD_test.
Fit IPCA on train only and reuse it for test (Activations.load_ipca_models) ->
shared basis, no train->test leakage.
- scripts: generate both splits; benchmark uses --skip_pca --ceiling_normalize.
- tests: score_train_test prediction, ceiling scaling, deterministic bootstrap,
null control. Full suite 96 passed.
Refs #9.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Update: reworked to fit-train / score-test with a real noise ceiling (commit 6a3a409)Inspecting
What changed
Gate green (ruff/ruff-format/mypy) and 96 tests pass. Not yet run on real activations — that's the next step (blocked only on a working torch env on Oscar). |
Smoke-tested end-to-end on Oscar ✅Ran the reworked pipeline on real TVSD data (alexnet, monkeyF, region IT) — deliberately tiny (512 train images) just to validate the plumbing, not to produce real numbers. Generation (
Benchmark (
Null control ( Env note for anyone reproducing on Oscar: the default PyPI torch wheel is Not run at scale yet (full 22,248-image train generation across models/regions is a separate |
Addresses all substantive deviations catalogued in #9, using the hybrid default policy: align the low-risk mechanical defaults to Brain-Score, but keep ceiling normalization opt-in (it changes the score's meaning most).
Changes per issue item
--ceiling_normalizedivides the score by the median per-neuroid noise ceiling;--ceiling_sb_correctapplies Spearman-Brown to the reliability firstutils.brainscore.spearman_brown()helper +spearman_brown=option onTVSD_TestDataset._compute_reliability(test-set path can now produce an SB-corrected ceiling)--standardize; default off to match Brain-Score'sscale=False+ internal PLS centeringShuffleSplit(n_splits=10, train_size=0.9);--cv_strategy kfoldretained--skip_pcafor pre-reduced featuresThe conflated
--preprocessedflag is replaced by--standardize/--skip_pca.scripts/benchmark.shupdated accordingly (now--skip_pca --n_splits 10, with a comment on the IPCA leakage caveat).Not changed (intentional)
Low-reliability neuroid dropping (
reliability > threshold) is kept — it follows the original TVSD paper, per maintainer direction. Ceiling normalization is independent of it.Test plan
tests/test_brainscore.py:spearman_brownvalues/monotonicity,_make_splitter,compute_brain_scorepredicts strongly-correlated data, ceiling normalization scales the score,ceiling_normalizewithout a ceiling raises, reproducibility.tests/test_reliability.py.Closes #9.
🤖 Generated with Claude Code