serliezer commited on
Commit
8794cbb
·
verified ·
1 Parent(s): 722992e

Add run_model_family_balanced.py

Browse files
scripts/run_model_family_balanced.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Run model-family ablation with balanced config selection."""
3
+ import os, sys, yaml, json, time
4
+ from datetime import datetime
5
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
+
7
+ from scripts.run_synthetic import build_model_family_grid, run_single_config
8
+ from src.utils import save_jsonl, ensure_dir
9
+
10
+ with open('config/synthetic_grid.yaml') as f:
11
+ cfg = yaml.safe_load(f)
12
+
13
+ configs = build_model_family_grid(cfg)
14
+
15
+ # Select balanced: 8 per family
16
+ pg = [c for c in configs if c['model_family']=='poisson_gamma'][:8]
17
+ gg = [c for c in configs if c['model_family']=='gaussian_gaussian'][:8]
18
+ gm = [c for c in configs if c['model_family']=='gaussian_gamma_map'][:8]
19
+ selected = pg + gg + gm
20
+
21
+ print(f"Running {len(selected)} balanced configs: {len(pg)} PG, {len(gg)} GG, {len(gm)} GM")
22
+
23
+ output_dir = ensure_dir('results/raw')
24
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
25
+ output_file = os.path.join(output_dir, f'model_family_balanced_{timestamp}.jsonl')
26
+
27
+ all_records = []
28
+ for idx, config in enumerate(selected):
29
+ print(f"\n>>> Config {idx+1}/{len(selected)} ({config['model_family']})")
30
+ try:
31
+ records = run_single_config(config, mode='model_family')
32
+ all_records.extend(records)
33
+ save_jsonl(records, output_file)
34
+ print(f" Saved {len(records)} records (total: {len(all_records)})")
35
+ except Exception as e:
36
+ print(f" ERROR: {e}")
37
+ import traceback
38
+ traceback.print_exc()
39
+
40
+ print(f"\nCompleted. Total: {len(all_records)} records in {output_file}")