Commit 2c41b90
authored
Resolve names from master_enrichment, the one base table (#276)
* refactor(data): resolve names from master_enrichment, the one base table (#224)
app.py built its own name lookup from properties.parquet and then merged iupac_backfill.parquet
itself. build_enrichment.py had already done that work — and better — so the two diverged in three
ways, all silent:
1. The enrichment build resolves a name curated-list-first, then PubChem common name, then IUPAC
name, then a molecular-formula fallback, un-inverting CAS-style ordering along the way. None
of that reached app.py's table.
2. The merge read only `iupac_name` from the backfill and ignored the `common_name` column, so
every PubChem Title the crawler recovered was thrown away on arrival.
3. Nothing carried the formula fallback, so the molecules that only have one resolved to nothing.
Measured before the change: 754 molecules had a name in master_enrichment that app._NAME_TABLE did
not know — and not obscure ones. cedrol, fenchyl alcohol, hydroxycitronellal and musk ketone all
rendered by name in the grid and came back empty from the UI's own lookup. After: 0.
Sourcing the resolved name straight off the base table makes the grid and the lookup agree by
construction instead of by coincidence, and deletes a whole merge function rather than adding one.
That is what #224 is actually asking for, applied where the duplication genuinely was.
Note what is deliberately NOT folded in. profile_index.npz is an 8,850 x 183 matrix — that 183 is
the FLAVOUR-PROFILE vector (6 taste + 172 aroma + 5 mouthfeel), not the head count, which is 195.
The 12 Tox21 heads are excluded on purpose: safety is not a flavour-match dimension and must never
steer "what tastes similar". flavor_map.parquet is a UMAP embedding. Different shapes serving
different questions; forcing either into a row-oriented molecule table would be worse, not tidier.
odor_notes/taste_notes are documented-text SOURCES the enrichment build consumes — upstream of the
base table, not competitors to it.
Signed-off-by: Austin L. <86896075+rvnminers-A-and-N@users.noreply.github.com>
* docs: sweep every head and profile-dimension number to the live roster
Prompted by a fair question — "don't we have more heads now?" — which turned out to be pointing at
a genuinely ambiguous line. Two different numbers had been drifting:
195 trained heads 6 taste + 172 aroma + 5 mouthfeel + 12 safety
183 profile dimensions 6 taste + 172 aroma + 5 mouthfeel (tox EXCLUDED, deliberately)
Tox is kept out of the flavour-profile vector on purpose: safety is not a flavour-match dimension,
and if it were in there two molecules could rank as "similar tasting" partly because they share a
liver-toxicity signature. That is wrong in a formulation tool and dangerous in a food one.
The stale numbers were spread across the schema, six docs and three source files — 175/177/178-dim
profiles and 166/167-head rosters, each correct at some point in the last two days. The pgvector
column was the worst of them: vector(177) would have rejected every insert of a 183-dim profile at
runtime, and nothing would have caught it until the first real docker compose up.
Also corrects a comment in predict.py that was not merely stale but actively wrong. It claimed the
model load "is fanned out across cores (joblib.load releases the GIL)". Both halves are false —
unpickling is GIL-bound, which is why threads measured ~2.5x SLOWER, and the process pool that IS
faster deadlocks because loading runs during module import. Anyone optimising from that comment
would have re-walked the exact path #225 documents as a dead end.
Signed-off-by: Austin L. <86896075+rvnminers-A-and-N@users.noreply.github.com>
---------
Signed-off-by: Austin L. <86896075+rvnminers-A-and-N@users.noreply.github.com>1 parent 7e58b84 commit 2c41b90
16 files changed
Lines changed: 67 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
| 139 | + | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments