Matthew Ford commited on
Commit
cc71055
·
unverified ·
1 Parent(s): d854014

chore: remove temporary diagnostic scripts

Browse files
scripts/_tmp_check_vocabs.py DELETED
@@ -1,19 +0,0 @@
1
- import json
2
- from pathlib import Path
3
-
4
- vocab_a = json.loads(Path('data/odor_descriptor_vocab.json').read_text())
5
- vocab_b = json.loads(Path('data/pyrfume_vocabulary.json').read_text())
6
- if isinstance(vocab_b, dict):
7
- vocab_b = vocab_b.get('vocabulary', list(vocab_b.keys()))
8
-
9
- print('odor_descriptor_vocab', len(vocab_a), vocab_a[:10])
10
- print('pyrfume_vocabulary', len(vocab_b), vocab_b[:10])
11
- print('same?', vocab_a == vocab_b)
12
- print('intersection', len(set(vocab_a) & set(vocab_b)))
13
-
14
- desc = json.loads(Path('data/pyrfume_descriptors_by_cas.json').read_text())
15
- print('pyrfume descriptor records', len(desc))
16
- print('sample keys', list(desc.keys())[:5])
17
-
18
- odt = json.loads(Path('data/pyrfume_odt_by_cas.json').read_text())
19
- print('pyrfume odt records', len(odt))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/_tmp_inspect_dataset.py DELETED
@@ -1,14 +0,0 @@
1
- import json
2
- from pathlib import Path
3
-
4
- lines = Path('data/empirical_dataset_v1.jsonl').read_text().splitlines()
5
- rec = json.loads(lines[0])
6
- print('formula type', type(rec['formula']))
7
- print('formula len', len(rec['formula']))
8
- print('first item', rec['formula'][0] if isinstance(rec['formula'], list) else rec['formula'])
9
- print('trajectory type', type(rec['trajectory']))
10
- print('trajectory len', len(rec['trajectory']))
11
- print('trajectory first item', rec['trajectory'][0] if isinstance(rec['trajectory'], list) else rec['trajectory'])
12
- print('objective_targets shape', len(rec['objective_targets']), len(rec['objective_targets'][0]))
13
- print('metadata', rec.get('metadata'))
14
- print('genre', rec.get('genre'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/_tmp_maxvar.py DELETED
@@ -1,20 +0,0 @@
1
- import json
2
- import numpy as np
3
- from pathlib import Path
4
-
5
- lines = Path('data/empirical_dataset_v2.jsonl').read_text().splitlines()
6
- records = [json.loads(l) for l in lines]
7
-
8
- variances = []
9
- for rec in records:
10
- obj = np.array(rec['objective_targets'])
11
- variances.append(float(obj.var(axis=0).mean()))
12
-
13
- variances = np.array(variances)
14
- idx = int(np.argmax(variances))
15
- print('max variance record', idx, variances[idx])
16
- print('genre', records[idx].get('genre'))
17
- print('metadata', records[idx].get('metadata'))
18
- print('formula', [(c.get('cas'), c.get('name'), c.get('weight_fraction')) for c in records[idx]['formula']])
19
- print('objective_targets first 5 rows', records[idx]['objective_targets'][:5])
20
- print('objective_targets last 5 rows', records[idx]['objective_targets'][-5:])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/_tmp_oav_variance.py DELETED
@@ -1,35 +0,0 @@
1
- import json
2
- import numpy as np
3
- from pathlib import Path
4
-
5
- lines = Path('data/empirical_dataset_v1.jsonl').read_text().splitlines()[:1000]
6
- records = [json.loads(l) for l in lines]
7
-
8
- variances = []
9
- for rec in records:
10
- traj = rec['trajectory']
11
- t_steps = len(traj)
12
- s_ing = len(rec['formula'])
13
- oav = np.zeros((t_steps, s_ing))
14
- for t, step in enumerate(traj):
15
- oav_step = step.get('OAV', {})
16
- for s, comp in enumerate(rec['formula']):
17
- cas = comp.get('cas', '')
18
- if cas.startswith('NATURAL:'):
19
- cas = cas[len('NATURAL:'):]
20
- oav[t, s] = oav_step.get(cas, 0.0)
21
- # Mean CV of OAV per ingredient across time.
22
- mean_per_ing = oav.mean(axis=0)
23
- std_per_ing = oav.std(axis=0)
24
- cv = (std_per_ing / (mean_per_ing + 1e-8)).mean()
25
- variances.append(cv)
26
-
27
- print('mean CV', np.mean(variances))
28
- print('median CV', np.median(variances))
29
- print('max CV', np.max(variances))
30
-
31
- # Check a single-ingredient record.
32
- for rec in records:
33
- if len(rec['formula']) == 1:
34
- print('single ing OAV', [step['OAV'][rec['formula'][0]['cas']] for step in rec['trajectory'][:5]])
35
- break
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/_tmp_poll_job.py DELETED
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Poll HF job status and print concise summary."""
3
- import os
4
- import sys
5
- import json
6
- from pathlib import Path
7
- from huggingface_hub import HfApi
8
-
9
- token = os.environ.get('HF_TOKEN') or Path('/tmp/hf_token.txt').read_text().strip()
10
- api = HfApi(token=token)
11
- job_id = sys.argv[1] if len(sys.argv) > 1 else 'mattbitzesty/6a4e88fc1499512f23779daa'
12
- job = api.get_job(job_id)
13
- print(json.dumps({
14
- 'id': job.id,
15
- 'status': job.status.stage,
16
- 'created_at': job.created_at,
17
- 'started_at': job.started_at,
18
- 'flavor': job.flavor,
19
- }, indent=2, default=str))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/_tmp_vocab_overlap.py DELETED
@@ -1,23 +0,0 @@
1
- import json
2
- from pathlib import Path
3
- from collections import Counter
4
-
5
- formulas = [json.loads(line) for line in Path('data/tgsc_demo_formulas_enriched.jsonl').open()]
6
- cache = json.loads(Path('data/tgsc_odor_cache.json').read_text())
7
-
8
- tgsc_words = set()
9
- for entry in cache.values():
10
- for word in entry.get('odor_type', []):
11
- tgsc_words.add(word.lower())
12
- for desc in entry.get('odor_descriptions', []):
13
- for word in desc.split():
14
- tgsc_words.add(word.lower().strip('.,;'))
15
-
16
- vocab = json.loads(Path('data/odor_descriptor_vocab.json').read_text())
17
- vocab_set = set(vocab)
18
-
19
- print('TGSC unique words:', len(tgsc_words))
20
- print('Vocab words:', len(vocab))
21
- overlap = tgsc_words & vocab_set
22
- print('Overlap:', len(overlap), f'{len(overlap)/len(vocab)*100:.1f}%')
23
- print('Missing vocab words:', sorted(vocab_set - tgsc_words)[:30])