From 5ee4bc1c735ac62ae0e33998d7c7625bf8b38d53 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 29 Jul 2026 14:12:08 +0200 Subject: [PATCH 1/2] seed novel's internal validation split The competition batches s1d2/s3d7 aren't in bmmc_multiome, so both multiome datasets fall through to an unseeded np.random.choice and pick different validation batches on every run. Add --seed and log the pick. --- CHANGELOG.md | 6 ++++++ src/methods/novel/novel_train/config.vsh.yaml | 5 +++++ src/methods/novel/novel_train/script.py | 7 +++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9a8396c..7d9ea278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# task_predict_modality 0.2.0 + +## BUG FIXES + +* `novel_train`: Seed the fallback that picks the internal validation batches, and log which ones were picked. Both `bmmc_multiome` datasets take this path, so the checkpoint `novel` kept differed from run to run (PR #46). + # task_predict_modality 0.1.1 ## NEW FUNCTIONALITY diff --git a/src/methods/novel/novel_train/config.vsh.yaml b/src/methods/novel/novel_train/config.vsh.yaml index 9acd4def..44433116 100644 --- a/src/methods/novel/novel_train/config.vsh.yaml +++ b/src/methods/novel/novel_train/config.vsh.yaml @@ -1,5 +1,10 @@ __merge__: ../../../api/comp_method_train.yaml name: novel_train +arguments: + - name: "--seed" + type: "integer" + description: "Seed for choosing the internal validation batches, when the dataset does not contain the batches used in the competition." + default: 1 resources: - path: script.py type: python_script diff --git a/src/methods/novel/novel_train/script.py b/src/methods/novel/novel_train/script.py index 0cd94124..89cf89f5 100644 --- a/src/methods/novel/novel_train/script.py +++ b/src/methods/novel/novel_train/script.py @@ -23,7 +23,8 @@ par = { 'input_train_mod1': 'resources_test/task_predict_modality/openproblems_neurips2021/bmmc_multiome/normal/train_mod1.h5ad', 'input_train_mod2': 'resources_test/task_predict_modality/openproblems_neurips2021/bmmc_multiome/normal/train_mod2.h5ad', - 'output': 'resources_test/task_predict_modality/openproblems_neurips2021/bmmc_multiome/normal/models/novel' + 'output': 'resources_test/task_predict_modality/openproblems_neurips2021/bmmc_multiome/normal/models/novel', + 'seed': 1 } meta = { 'resources_dir': 'src/methods/novel', @@ -75,7 +76,9 @@ # if none of phase1_batch is in batch, sample 25% of batch categories rounded up if len(test_batches.intersection(set(batch))) == 0: all_batches = batch.cat.categories.tolist() - test_batches = set(np.random.choice(all_batches, math.ceil(len(all_batches) * 0.25), replace=False)) + rng = np.random.default_rng(par['seed']) + test_batches = set(rng.choice(all_batches, math.ceil(len(all_batches) * 0.25), replace=False)) +print(f"Using {sorted(test_batches)} as internal validation batches", flush=True) train_ix = [ k for k,v in enumerate(batch) if v not in test_batches ] test_ix = [ k for k,v in enumerate(batch) if v in test_batches ] From 79af3a4530192926b6e6dc48690c2b7ed7ed2838 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 30 Jul 2026 19:11:00 +0200 Subject: [PATCH 2/2] log the validation batches as plain strings --- src/methods/novel/novel_train/script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/methods/novel/novel_train/script.py b/src/methods/novel/novel_train/script.py index 4c899d3e..91e35885 100644 --- a/src/methods/novel/novel_train/script.py +++ b/src/methods/novel/novel_train/script.py @@ -79,7 +79,7 @@ if len(test_batches.intersection(set(batch))) == 0: all_batches = batch.cat.categories.tolist() rng = np.random.default_rng(par['seed']) - test_batches = set(rng.choice(all_batches, math.ceil(len(all_batches) * 0.25), replace=False)) + test_batches = set(map(str, rng.choice(all_batches, math.ceil(len(all_batches) * 0.25), replace=False))) print(f"Using {sorted(test_batches)} as internal validation batches", flush=True) train_ix = [ k for k,v in enumerate(batch) if v not in test_batches ] test_ix = [ k for k,v in enumerate(batch) if v in test_batches ]