Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e79e8ed16 | ||
|
|
2ca33edaa4 | ||
|
|
a5ae3a4605 | ||
|
|
ad1e789e8e | ||
|
|
32d1e27fc5 |
@@ -1,5 +0,0 @@
|
||||
# extracted person-level data + generated artifacts — never commit
|
||||
cache/
|
||||
reports/
|
||||
*.log
|
||||
__pycache__/
|
||||
@@ -1,518 +0,0 @@
|
||||
# Multiplicator detection — offline pipeline
|
||||
|
||||
Detects **multiplicators** among an institution's researchers — *bridgers* (connect
|
||||
disconnected research communities), *mentors* (bring up junior/debutant co-authors), and
|
||||
*amplifiers* (patents, industry co-authorship, news visibility) — from OpenAlex plus the
|
||||
patent/project/news sources, and writes per-author scores + tags + evidence to a derived
|
||||
Elasticsearch index.
|
||||
|
||||
Follows the repo's offline pattern (`scripts/patents/index_org_patents.py`): all analysis
|
||||
and joining happen **offline**, the result lands in a **separate, institution-parameterised
|
||||
ES index**, and a thin read-only backend router is added only once the UI needs it.
|
||||
|
||||
**New here? Read [ROADMAP.md](docs/ROADMAP.md) first** — a ground-up explanation of the
|
||||
concept, every index field, the related work behind the metrics, and what's next.
|
||||
|
||||
## Status
|
||||
|
||||
**M0 — spike: done. M1 — metrics core: done** (exit check PASS). **M2 — pipeline +
|
||||
`multiplicators_v1` index: done** (idempotency verified). **M3 — amplifier signal
|
||||
joins: wired and indexed** (patents / news / CORDIS; results below) — remaining:
|
||||
the coach calibration session. **M4 — read router:** pending, once the UI needs it.
|
||||
All results per milestone are documented in the sections below.
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
cd service/scripts/multipliers
|
||||
python -m venv .venv && source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Credentials are read from `service/src/main/inse/.env`:
|
||||
- `ELASTICSEARCH_URL` / `ELASTICSEARCH_API_KEY` — NES cluster (OpenAlex).
|
||||
- `ELASTICSEARCH_INSE_URL` / `ELASTICSEARCH_INSE_API_KEY` — INSE cluster (patents, news).
|
||||
|
||||
## Run the spike
|
||||
|
||||
```bash
|
||||
# Extract + audit for University of Duisburg-Essen (writes cache/ + report json)
|
||||
python spike_audit.py --institution-id I62318514
|
||||
|
||||
# Re-audit from the cache without re-hitting ES
|
||||
python spike_audit.py --institution-id I62318514 --skip-extract
|
||||
|
||||
# Also test write/delete permissions on the INSE cluster (throwaway index)
|
||||
python spike_audit.py --institution-id I62318514 --probe-writes
|
||||
```
|
||||
|
||||
Outputs land in `cache/`:
|
||||
- `authors_<ID>.jsonl.gz` — the two-group author union.
|
||||
- `works_<ID>.jsonl.gz` — full-authorship works (external co-authors + institutions).
|
||||
- `spike_report_<ID>.json` — the audit report.
|
||||
|
||||
The report answers: reproduction (author/work counts), field coverage
|
||||
(`author_position` / `is_corresponding` / institution `type`), scale (authors-per-work
|
||||
histogram, pair counts at caps 20/50/100), career quality (suspicious-profile %,
|
||||
`active_years` distribution), signal reachability (`org_patents` match-type breakdown),
|
||||
and write permissions.
|
||||
|
||||
`cache/` is disposable and should not be committed (it can be hundreds of MB and contains
|
||||
extracted person data).
|
||||
|
||||
---
|
||||
|
||||
## M0 spike results (I62318514, run 2026-07-15)
|
||||
|
||||
The spike existed to answer six questions the whole design was betting on. Full raw
|
||||
numbers in `cache/spike_report_I62318514.json`; this section explains each stat, why it
|
||||
was measured, and which downstream metric it feeds.
|
||||
|
||||
### 1. Reproduction — is the extraction correct?
|
||||
|
||||
| Stat | Value | Meaning |
|
||||
|---|---|---|
|
||||
| Author count | **4,921** | Exactly reproduces the audited seed extraction (`llm_evaluations/basic_applied_experimental/ude_audit_report.json`). Our port of the query is faithful. |
|
||||
| — `backend_compatible` group | 4,740 | Authors with `last_known_institutions == UDE` **and** a recent UDE affiliation. |
|
||||
| — `empty_last_known_recent` group | 181 | Authors with a recent UDE affiliation but **no** `last_known_institutions` at all. Without this second query group, 3.7% of the cohort would silently vanish — this is why the author set is a *union of two queries*, not one. |
|
||||
| Work count | **183,661** | All works by those 4,921 authors, globally, unrestricted by institution or year. Matches the seed audit. |
|
||||
|
||||
**Contributes to:** everything. This is the corpus. The "all works globally" property is
|
||||
load-bearing for the career metrics: it means `active_years` is *exact* for in-set
|
||||
authors (we see their complete history), while for external co-authors we only see works
|
||||
shared with UDE — which is why mentor metrics are restricted to UDE-internal pairs.
|
||||
|
||||
### 2. Field coverage — are the fields the metrics need actually populated?
|
||||
|
||||
The OpenAlex Pydantic models declare these fields, but that says nothing about whether
|
||||
the ES index actually populates them. Two sub-scores would have died silently.
|
||||
|
||||
| Stat | Value | Feeds | Verdict |
|
||||
|---|---|---|---|
|
||||
| Authorships total | 3,805,507 | — | denominator |
|
||||
| `author_position` populated | **100%** | `last_author_with_junior_first` (mentor): the classic supervision signature — PI last, junior first. | ✅ computable |
|
||||
| `is_corresponding` populated | **100%** | reserved for later refinement (corresponding-author weighting). | ✅ available |
|
||||
| `institutions.type` populated | **99.91%** | `cross_sector_share` / `industry_coauthor_share` (bridger + amplifier): share of works with a co-author at `type == "company"`. | ✅ computable |
|
||||
| Company-institution occurrences | **67,131** | same | dense enough to rank on — this is the strongest *ID-linked* industry signal we have, stronger than any name-matched source. |
|
||||
|
||||
**Contributes to:** confirms the metric set needs no fallbacks. Had `institutions.type`
|
||||
been empty, the amplifier would have collapsed onto 123 high-confidence patents (see §6).
|
||||
|
||||
### 3. Scale — where does the pair explosion land, and what cap do we need?
|
||||
|
||||
Co-author pair generation is quadratic per work: a work with *n* authors yields
|
||||
*n·(n−1)/2* pairs. The distribution of authors-per-work decides whether the self-join is
|
||||
feasible locally and where to cap it.
|
||||
|
||||
| Stat | Value |
|
||||
|---|---|
|
||||
| Authors per work p50 / p90 / p99 / max | **5 / 17 / 144 / 4,839** |
|
||||
| Works with > 100 authors | **2,459** (1.3%) |
|
||||
| Pair instances at cap 20 / 50 / 100 | **3.9M / 8.0M / 13.9M** |
|
||||
|
||||
**Why `max_authors_per_work` matters** (the cap): the max-4,839-author work alone would
|
||||
generate ~11.7M pairs — more than the *entire rest of the corpus* at cap 50 — and a
|
||||
hyperauthored consortium paper (CERN/medical mega-trials) carries no real collaboration
|
||||
signal: being 1 of 4,839 names says nothing about who actually works with whom, but it
|
||||
*would* create a giant artificial clique that inflates betweenness and strength for
|
||||
everyone on it, poisoning the bridger score. The cap drops works above the threshold
|
||||
from **graph construction only** — they still count for publication years / `active_years`.
|
||||
|
||||
**Chosen: `max_authors_per_work = 50`.** Rationale: p90 = 17, so a cap of 50 keeps ≥ 99%
|
||||
of works (cap sits well above p90, below p99 = 144) while excluding only true
|
||||
hyperauthorship; the resulting 8.0M pair instances collapse to ~1–2M distinct edges,
|
||||
comfortably in-memory for polars. It's a config value (`extraction.max_authors_per_work`),
|
||||
not code — tunable per institution.
|
||||
|
||||
**Contributes to:** graph construction (Stage C); confirms the "pure local compute, no
|
||||
DuckDB/warehouse" bet.
|
||||
|
||||
### 4. Career quality — can we bucket careers, and how bad is profile merging?
|
||||
|
||||
Background: `analysis/career_stage/` established that `first_publication_year` is
|
||||
unreliable at UDE (merged OpenAlex profiles → debut years of 1893/1906 for active
|
||||
professors) and that `active_years` (distinct years with ≥ 1 publication) is robust.
|
||||
The pipeline therefore buckets by `active_years` and uses prefix-counted
|
||||
`active_years_at(A, Y)` instead of debut years for the mentor metrics.
|
||||
|
||||
| Stat | Value | Meaning / use |
|
||||
|---|---|---|
|
||||
| Suspicious profiles | **225 (4.6%)** | `first_year < 1970 or career_span > 60` (same flag as `persons/logic.py`). These are likely *merged identities*. They are **not dropped** — their `active_years` is still fine — but their evidence is marked `low_confidence`. Especially important for the **bridger** score: a merged profile is one node standing in for two people and *systematically* fakes bridging. |
|
||||
| `active_years` p50 / p90 / max / mean | **4 / 25 / 60 / 8.9** | p50 = 4 means **half the cohort is career-stage "Early" (≤ 4)**. This is why percentile normalization happens *within career buckets* (Early/Emerging/Established/Senior via `_classify_career_stage`): institution-wide percentiles would just rank seniority, and no early-career person could ever surface as a multiplicator. |
|
||||
|
||||
**Contributes to:** career bucketing (scoring), mentor junior/senior thresholds,
|
||||
confidence flags on evidence.
|
||||
|
||||
### 5. Permissions — can we ship the result anywhere?
|
||||
|
||||
Initial spike: `PUT` to create an index on the INSE cluster → **403** (key can read, not
|
||||
create). Resolved 2026-07-15: **`multiplicators_v1` was created by the cluster admin**,
|
||||
and the standard INSE key can now write to it (verified: doc create + delete both
|
||||
succeed). The build step must therefore *never* try to create/re-create the index — only
|
||||
delete-by-institution + bulk-index into the existing one (same constraint as
|
||||
`org_patents`, whose key also rejects `_delete_by_query`; use the search + bulk-delete
|
||||
loop from `patents/org/elastic_search_client.py`).
|
||||
|
||||
**Contributes to:** M2 index/build design.
|
||||
|
||||
### 6. Signal reachability — which amplifier sources are real?
|
||||
|
||||
| Stat | Value | Meaning |
|
||||
|---|---|---|
|
||||
| `org_patents` docs for UDE | **436** | The patent→OpenAlex-author link index exists and is populated. |
|
||||
| — `match_type: name` | 313 | Name-only match. **Evidence only, weight 0** — name matching is the weakest link type. |
|
||||
| — `match_type: both` | 65 | Institution assignee **and** name match — highest confidence. **Scores.** |
|
||||
| — `match_type: institution` | 58 | Institution-assignee match. **Scores.** |
|
||||
|
||||
**Contributes to:** amplifier sub-score. Only 123 patents are high-confidence, so patents
|
||||
are a *secondary* amplifier signal; the primary is `industry_coauthor_share` (67k
|
||||
ID-linked company co-authorships, §2). News (`aktuell_postproc`, exact-string person
|
||||
match) enters at low weight; DFG (token containment) and Bund (no person link) are
|
||||
excluded entirely.
|
||||
|
||||
### Spike exit criteria — all met (see below for M1)
|
||||
|
||||
- ✅ Extraction reproduces the audited counts exactly.
|
||||
- ✅ Every planned metric is confirmed computable — no fallbacks needed.
|
||||
- ✅ `max_authors_per_work = 50` chosen from measured data.
|
||||
- ✅ Write path to `multiplicators_v1` verified end-to-end.
|
||||
- ✅ Amplifier signal priorities re-ordered based on measured density
|
||||
(industry co-authorship primary, patents secondary).
|
||||
|
||||
---
|
||||
|
||||
## M1 results (metrics core, run 2026-07-15)
|
||||
|
||||
Modules: `graph.py` (co-author graph via polars self-join, decay weights, hyperauthorship
|
||||
cap), `metrics.py` (Brandes betweenness with inverted weights, Burt constraint on the
|
||||
full graph incl. externals, field entropy, industry co-author share, debut-year-free
|
||||
mentor metrics on `active_years_at`), `scoring.py` + `multipliers.yaml`
|
||||
(within-career-bucket percentiles → weighted sub-scores → tags). 26 unit tests
|
||||
(`pytest`), including exact agreement with networkx oracles for betweenness/constraint
|
||||
and the planted-1893-outlier regression guard for `active_years_at`.
|
||||
|
||||
Run with:
|
||||
|
||||
```bash
|
||||
python build.py --institution-id I62318514 # scores + summary from the cache
|
||||
python validate_sample.py --institution-id I62318514 # 60-person exit check
|
||||
```
|
||||
|
||||
### Full-corpus run (I62318514)
|
||||
|
||||
| Stat | Value |
|
||||
|---|---|
|
||||
| Runtime end-to-end | **2.6 min** (load 15s, graph 31s, metrics 112s) — exit criterion was < 15 min |
|
||||
| Graph | 639,544 nodes (4,921 focal + externals), 4,143,499 edges |
|
||||
| Works used / capped | 160,396 / 4,823 (`max_authors_per_work = 50`) |
|
||||
| Tags at threshold 0.85 | bridger 66, mentor 91, amplifier 609 |
|
||||
|
||||
The amplifier tag count is inflated for now: only `industry_coauthor_share` exists at M1
|
||||
(patents/news/CORDIS join in M3), so weight redistribution makes it a single-metric
|
||||
sub-score. Ignore amplifier tags until M3.
|
||||
|
||||
### M1 exit check — PASS
|
||||
|
||||
Against the 60 hand-labeled researchers in `analysis/career_stage/career_stage_sample.csv`
|
||||
(31 Professor / 29 Researcher), mentor scores must concentrate on professors:
|
||||
|
||||
| known status | n | median mentor score |
|
||||
|---|---|---|
|
||||
| Professor | 25 | **0.715** |
|
||||
| Researcher | 18 | 0.493 |
|
||||
|
||||
Top of the list is face-valid: senior professors with 30–50 mentored juniors and strong
|
||||
last-author-with-junior-first signatures (Bacher, Sures, Hering, Gunzer, …). The two
|
||||
high-scoring "Researchers" are informative, not embarrassing: e.g. a core-facility
|
||||
scientist with 37 juniors but **zero** last-author works — the independent supervision
|
||||
signature correctly separates "publishes with many juniors" from "supervises them".
|
||||
|
||||
### ⚠ Cohort-coverage finding (must be decided in M2)
|
||||
|
||||
17 of the 60 sample people are missing from the 4,921-author cohort. Diagnosed causes:
|
||||
|
||||
1. **University-hospital clinicians are systematically excluded.** Prominent UDE
|
||||
medicine professors (e.g. Witzke, Bingel) have
|
||||
`last_known_institutions = Essen University Hospital (I4210119759)`, and the
|
||||
hospital is **not** in UDE's OpenAlex lineage — OpenAlex models it as a *related*
|
||||
institution, not a child. **2,437 active (2025+) authors** sit behind this gap —
|
||||
roughly half a cohort. Fix: make the cohort definition accept a list of
|
||||
institution IDs (`I62318514` + `I4210119759` + …) per deployment, sourced from
|
||||
`associated_institutions` and confirmed by a human.
|
||||
2. **Stale affiliation years exclude current staff.** E.g. Saccà has
|
||||
`last_known = UDE` but no `affiliations.years >= 2025` entry, so the recency
|
||||
filter drops her. Fix candidates: widen the window (>= 2023), or accept
|
||||
`last_known = UDE` alone with a works-recency check.
|
||||
|
||||
Both are extraction-time cohort decisions with precision/recall tradeoffs — they belong
|
||||
to the coaches/product owner, not to code defaults.
|
||||
|
||||
---
|
||||
|
||||
## M1 validation in detail (what was checked, against what ground truth)
|
||||
|
||||
### The ground truth
|
||||
|
||||
`analysis/career_stage/career_stage_sample.csv` — 60 UDE researchers with manually
|
||||
researched **role labels** (`known_status`: 31 Professor / 29 Researcher incl. doctoral),
|
||||
across five discipline groups (Biology, CS, Engineering, Medicine, Sociology), each with
|
||||
an OpenAlex author ID (so the join to our scores is exact — no name matching involved).
|
||||
The sample was originally built for the career-stage analysis; it does **not** label
|
||||
anyone as a "multiplicator" — no such ground truth exists yet (that is the M3 golden set
|
||||
the innovation coaches will provide).
|
||||
|
||||
### What exactly was evaluated
|
||||
|
||||
One directional sanity check on the riskiest sub-score: *supervision is part of the
|
||||
professor role, so if the mentor sub-score measures anything like real mentorship,
|
||||
professors must score systematically higher than researchers.* Defined check:
|
||||
professors' **median mentor sub-score > researchers'**.
|
||||
|
||||
The check is stronger than it looks because scores are percentiles **within career
|
||||
buckets**: a Senior researcher is compared against Senior professors, not against PhD
|
||||
students, so a trivial "older people score higher" effect is largely normalized away —
|
||||
the gap has to come from mentor behaviour (juniors mentored, last-author-with-junior-
|
||||
first works), not raw seniority.
|
||||
|
||||
### Results (UDE-only cohort, 2026-07-15; archived as `cache/*_I62318514.udeonly.json`)
|
||||
|
||||
43 of 60 matched (17 missing — see the cohort-coverage finding above). Medians:
|
||||
|
||||
| sub-score | Professor (n=25) | Researcher (n=18) | check |
|
||||
|---|---|---|---|
|
||||
| **mentor** | **0.715** | **0.493** | **PASS** |
|
||||
| bridger | 0.603 | 0.508 | (informational) |
|
||||
| amplifier | 0.655 | 0.413 | (single-metric until M3 — ignore) |
|
||||
|
||||
Ranking detail, more convincing than the medians:
|
||||
|
||||
- Top = senior professors with strong dual signals: Gerd Bacher (37 juniors, 16
|
||||
last-author-junior-first works), Bernd Sures (52, 24), Daniel Hering (35, 25),
|
||||
Matthias Gunzer (54 juniors).
|
||||
- Bottom = early-career researchers with 0 juniors.
|
||||
- The two high-scoring "Researchers" are the system working, not failing:
|
||||
Birte Möhlendick (0.924, 12 juniors) — plausibly a group leader whose formal title
|
||||
lags her role; Farnusch Kaschani (0.714, **37 juniors but 0 last-author works**) —
|
||||
the classic core-facility-scientist profile: on many students' papers without
|
||||
supervising them. The two mentor signals disagreeing on exactly this person is why
|
||||
`last_author_with_junior_first` exists as an independent cross-check.
|
||||
|
||||
### What this does NOT show
|
||||
|
||||
It validates the *direction* of the mentor proxy, not that top-ranked people are good
|
||||
mentors or multiplicators: professor-vs-researcher is a coarse label, n=43 is small,
|
||||
bridger has no ground truth in this sample, and amplifier is a single-metric score until
|
||||
M3. The real validation is the coach golden set (M3). This check is kept as a
|
||||
regression: re-run `validate_sample.py` after every weight change or dump refresh.
|
||||
|
||||
---
|
||||
|
||||
## Cohort fix + re-run (2026-07-15, config version 2)
|
||||
|
||||
The hospital gap above is fixed by a **configurable cohort list**: `cohorts.<primary-ID>.
|
||||
institution_ids` in `multipliers.yaml`. **How the list was discovered — and how to
|
||||
build one for another university — is documented in
|
||||
[ASSOCIATED_INSTITUTIONS.md](docs/ASSOCIATED_INSTITUTIONS.md).** For UDE it holds 9 institutions — UDE, Essen
|
||||
University Hospital, the West German Heart Center, the Erwin L. Hahn Institute, and the
|
||||
five OpenAlex lineage children (RISP, DTNW, KWI, ZBT, IUTA) — with the deliberate
|
||||
exclusions (Kliniken Essen-Mitte, the independent An-Institute) documented inline for
|
||||
the coaches to revisit. Candidates were sourced from `associated_institutions` in
|
||||
`openalex-institutions`; the extractor now matches `last_known_institutions` /
|
||||
`affiliations` by **institution ID terms** over the whole list.
|
||||
|
||||
### Before / after (UDE-only → 9-institution cohort)
|
||||
|
||||
| | UDE-only | cohort | note |
|
||||
|---|---|---|---|
|
||||
| Authors | 4,921 | **6,583** | +1,662, mostly hospital clinicians |
|
||||
| Works | 183,661 | **221,603** | |
|
||||
| Graph | 640k nodes / 4.14M edges | 764k / 5.26M | |
|
||||
| Pipeline runtime | 2.6 min | **4.5 min** | still far under the 15-min criterion |
|
||||
| Sample matched | 43/60 | **45/60** | Witzke + Bingel recovered |
|
||||
| Mentor exit check | 0.715 vs 0.493 PASS | **0.699 vs 0.493 PASS** | stable |
|
||||
| Tags (bridger/mentor/amplifier) | 66/91/609 | 96/131/763 | scales with cohort |
|
||||
|
||||
Face validity of the fix: both recovered professors immediately tag as mentors with
|
||||
strong evidence — Witzke (Senior, 73 juniors mentored), Bingel (Senior, 34 juniors,
|
||||
21 last-author-with-junior-first works).
|
||||
|
||||
### The remaining 15 missing, fully diagnosed
|
||||
|
||||
- **9 × correctly excluded** — they left UDE (`last_known` now Halle, Würzburg,
|
||||
Greifswald, OU Netherlands, ISG, or none). The sample is older than the corpus;
|
||||
these are not gaps.
|
||||
- **6 × stale-affiliation cases** — `last_known` IS in the cohort but their most
|
||||
recent cohort affiliation year is 2021–2024, so the `affiliation_years_gte: 2025`
|
||||
recency filter drops them. At least one (Saccà, last seen 2024) is a current
|
||||
professor — publication lag alone can push someone out of a 1-year window.
|
||||
**Recommendation for M2:** set `extraction.affiliation_years_gte: 2023` (already
|
||||
config) — captures normal publication lag while still excluding long-departed
|
||||
authors. Decide with the coaches; it trades a little precision for recall.
|
||||
|
||||
---
|
||||
|
||||
## M2 — pipeline + ES index (done 2026-07-15)
|
||||
|
||||
New modules: `extract.py` (canonical cohort-aware extraction, config-driven),
|
||||
`index.py` (`MultiplicatorsIndexClient` for `multiplicators_v1` on the INSE cluster),
|
||||
`build.py` (single entry point: extract → graph → metrics → scoring → index).
|
||||
`spike_audit.py` remains self-contained for auditing any institution.
|
||||
|
||||
```bash
|
||||
python build.py --institution-id I62318514 # full run (reuses cache)
|
||||
python build.py --institution-id I62318514 --force-extract # refresh from ES
|
||||
python build.py --institution-id I62318514 --no-index # local artifacts only
|
||||
```
|
||||
|
||||
### Index contract (`multiplicators_v1`, INSE cluster)
|
||||
|
||||
- Doc `_id` = `<institution_short>_<author_short>` (e.g. `I62318514_A5087456839`);
|
||||
one doc per author per institution.
|
||||
- Every doc: raw metrics, per-bucket percentiles, sub-scores, tags, career bucket,
|
||||
`suspicious_profile`, evidence (junior ids), `config_hash`, `computed_at`,
|
||||
`cohort_institution_ids`. Explicit mapping is PUT on every run (additive).
|
||||
- Idempotent re-runs: collect the institution's doc ids → bulk-delete → bulk-index →
|
||||
poll `_count` until the expected count is visible. **Verified: delete 9,474 →
|
||||
index 9,474 → count 9,474.**
|
||||
|
||||
### Key-permission gotchas (learned the hard way, encoded in `index.py`)
|
||||
|
||||
The admin-created index + standard INSE key allows: read, `_bulk` index/delete,
|
||||
`_mapping` updates, `_count`. It does **not** allow: index create/delete,
|
||||
`_delete_by_query` (same as org_patents), and — new finding — **`_refresh`
|
||||
(`indices:admin/refresh` → 403)**. A first client version silently relied on refresh
|
||||
and saw phantom docs during delete (stale visibility inflated the delete count) and a
|
||||
too-early post-index count. The client now never calls `_refresh`: it collects all doc
|
||||
ids BEFORE deleting, and verifies by polling `_count` (auto-refresh ≈ 1s) instead.
|
||||
|
||||
### Run with `affiliation_years_gte: 2023` (config v2 → v3)
|
||||
|
||||
| | 2025 cutoff | 2023 cutoff |
|
||||
|---|---|---|
|
||||
| Authors / works | 6,583 / 221,603 | **9,475 / 267,467** |
|
||||
| Graph | 764k nodes / 5.26M edges | 865k / 5.82M |
|
||||
| Full runtime (incl. extract + index) | — | **~14.5 min** |
|
||||
| Sample matched | 45/60 | **51/60** |
|
||||
| Mentor exit check | 0.699 vs 0.493 PASS | **0.740 vs 0.494 PASS** (wider gap) |
|
||||
|
||||
The 9 still-missing sample people are exactly the 9 confirmed leavers (last_known now
|
||||
Halle, Würzburg, Greifswald, …) — correct exclusions, zero unexplained gaps. All six
|
||||
stale-affiliation cases were recovered (some via 2023+ affiliations with the hospital /
|
||||
institute cohort members rather than UDE itself).
|
||||
|
||||
Career-bucket distribution in the index: Early 5,361 / Emerging 1,591 /
|
||||
Established 777 / Senior 1,745. Tags: bridger 133, mentor 161, amplifier 1,107
|
||||
(amplifier still single-metric until M3 — ignore).
|
||||
|
||||
### Next (M3)
|
||||
|
||||
Wire the signal joins into the amplifier score (`org_patents` match_type
|
||||
institution/both, news with name normalization at low weight, CORDIS DOI-join),
|
||||
then calibrate the YAML weights with the innovation coaches against their golden set.
|
||||
M4 (read router in `inse/`) once the UI needs it.
|
||||
|
||||
---
|
||||
|
||||
## M3 — amplifier signal joins (done 2026-07-15)
|
||||
|
||||
Before wiring, a live-index audit showed the amplifier was degenerate: its only input
|
||||
(`industry_coauthor_share`) was 0 for 61.5% of the cohort, and the "top amplifiers"
|
||||
were small-denominator ratio artifacts (share = 1.0 with 2 typed works). Two fixes:
|
||||
|
||||
1. **Shrinkage**: scoring now uses `industry_coauthor_share_shrunk = company/(typed+k)`
|
||||
(k=5, config `signals.industry_share_shrinkage_k`); the raw share stays in the doc.
|
||||
2. **Three independent signal joins** (`signals.py`), weights in YAML
|
||||
(shrunk share 0.50 / patents 0.25 / CORDIS 0.15 / news 0.10):
|
||||
|
||||
| signal | join mechanism | UDE yield (9,474 authors) |
|
||||
|---|---|---|
|
||||
| `patent_count` | `org_patents.matched_authors` author IDs, `match_type ∈ {institution, both}`; name-only kept as `patent_count_name_only` evidence, never scored | 55 authors (17 more name-only) |
|
||||
| `news_mentions` | `aktuell_postproc` LLM-extracted names, normalized-exact match (casefold + diacritic fold); a normalized name shared by >1 cohort authors credits NO ONE | 1,369 authors; **839 ambiguous names skipped** (precision over recall) |
|
||||
| `cordis_eu_projects` | DOI overlap with `cordis_eu_*_publications` → distinct projectIDs. **Case-insensitive term matching** — 21% of CORDIS DOIs contain uppercase and a plain `terms` query silently misses them | 1,342 authors |
|
||||
|
||||
Signal join runtime ≈ 9 min (the case-insensitive CORDIS batches dominate); total
|
||||
pipeline ≈ 20 min. Mentor/bridger untouched: validation unchanged (51/60, mentor
|
||||
check PASS 0.740 vs 0.494).
|
||||
|
||||
### Effect on the amplifier tag
|
||||
|
||||
Tags went **1,107 → 10**. With four independent inputs, a ≥0.85 *weighted mean* of
|
||||
within-bucket percentiles requires being near the top on most channels — the tag now
|
||||
means something. The new top-10 is face-valid (Wiltfang, Erbel, Kaiser, Schierning —
|
||||
patent-holding, industry-connected, media-visible seniors). Two open calibration
|
||||
questions for the coaches:
|
||||
|
||||
- **Threshold per tag?** 0.85 yields 133 bridgers / 161 mentors / 10 amplifiers.
|
||||
If more amplifier candidates are wanted, either lower a per-tag threshold
|
||||
(currently one global `tags.threshold`) or re-weight.
|
||||
- **Split-profile artifact**: an Early-bucket author with 1 active year made top-10
|
||||
amplifier — almost certainly a split OpenAlex profile of a senior professor
|
||||
(patents/news land on the fragment). Bucket-relative ranking amplifies fragments;
|
||||
the `suspicious_profile` flag does not catch splits (only merges). Known
|
||||
limitation — ORCID-based resolution is the deferred fix.
|
||||
|
||||
### M3 remaining
|
||||
|
||||
The **coach calibration session**: golden set of 10–20 known multiplicators, tune the
|
||||
YAML (weights, per-tag thresholds), re-run `validate_sample.py` as regression.
|
||||
|
||||
---
|
||||
|
||||
## Network visualization index (`multiplicator_networks_v1`, added 2026-07-16)
|
||||
|
||||
The scores index answers *what did this person score*; this companion index answers
|
||||
*who are they connected to and how* — everything a frontend needs to draw the
|
||||
ego-network figures (force layout, role colors, tooltips) without recomputing
|
||||
anything. Materialized by `build.py` (`networks.py`) while the full graph is in
|
||||
memory, because the **neighbor-neighbor edges** that make graph shape readable
|
||||
(dense mesh = one community; spokes with gaps = brokered structural holes) come from
|
||||
works that do NOT include the ego — no request-time query can reconstruct them.
|
||||
|
||||
One doc per focal author, `_id = <institution>_<author>` (same scheme as scores):
|
||||
|
||||
| field | content |
|
||||
|---|---|
|
||||
| `nodes[]` | `{id, name, role, inst, active_years, suspicious, company_insts?}`; role ∈ ego / mentee / cohort / industry / external. **`industry` is tie-level**: assigned only when a company affiliation of the neighbour appears on a work *shared with the ego* (matching what `industry_coauthor_share` counts), and `company_insts` names the triggering companies — a lifetime-flag version painted predominantly-academic people orange over a single old dual affiliation. `inst` is the author's most frequent institution. |
|
||||
| `edges[]` | `{a, b, w, n_works, cross, first_year, last_year}` — `w` = decayed tie strength, `cross` = mostly cross-institution |
|
||||
| `ego{}` | header duplicate (bucket, tags, sub_scores, max_sub_score) so a network endpoint renders standalone |
|
||||
| totals | `total_coauthors`, `cohort_coauthors`, `mentee_count`, `shown`, `shown_mentees` |
|
||||
| provenance | `config_hash`, `computed_at`, `cohort_institution_ids` |
|
||||
|
||||
Selection: strongest `network.max_nodes` (42) co-authors by tie weight with up to
|
||||
`network.max_forced_mentees` (14) mentees force-included first — mentees' ties are
|
||||
decayed and team-size-divided, so a pure top-by-weight cut hides exactly the people
|
||||
the mentor score is about. Positions are NOT stored: the webapp's echarts `graph`
|
||||
series (force layout) lays out at render time; map role → color, active_years →
|
||||
symbol size, `cross` → dashed line.
|
||||
|
||||
`nodes`/`edges` are mapped `"enabled": false` (stored, never indexed) — the index
|
||||
stays small and fast for the queryable header fields (`institution_id`, `author_id`,
|
||||
`ego.tags`, `computed_at`, …). Skip building with `--no-network`.
|
||||
|
||||
### Regenerating the HTML report
|
||||
|
||||
`make_report.py` renders a self-contained HTML report of four contrasting cases
|
||||
straight from the two live ES indices — no local cache required, so it works on any
|
||||
machine with cluster access after a build has run:
|
||||
|
||||
```bash
|
||||
python make_report.py --institution-id I62318514
|
||||
# -> reports/multiplier_networks.html (open in any browser; light/dark toggle)
|
||||
|
||||
python make_report.py --institution-id I62318514 \
|
||||
--author-ids A5113304257,A5043495754,A5007801159,A5123934012 # explicit cast
|
||||
```
|
||||
|
||||
The cast is pinned in `report.featured_author_ids` (config) so the report is
|
||||
reproducible across weight tunes and dump refreshes; `--author-ids` overrides it and
|
||||
`--auto` falls back to selecting the current top bridger / mentor / amplifier plus the
|
||||
highest-scoring person who carries **no** tag — the last one exposes where the
|
||||
thresholds bite (and, when that person's best sub-score is *above* 0.85, the
|
||||
`tags.min_active_years` guard that withholds tags from one-year profiles, which are
|
||||
usually **split** OpenAlex identities — the case `suspicious_profile` cannot catch,
|
||||
since that flag detects merges).
|
||||
|
||||
The page layout lives in `report_template.html` (tracked); `reports/` and `cache/` are
|
||||
gitignored, so a `git clean -fdx` or fresh checkout wipes generated reports and
|
||||
extracts — re-run the command above to rebuild the report, and `build.py` only if the
|
||||
indices themselves need refreshing.
|
||||
@@ -1,277 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
build.py — single entry point for the multiplicator pipeline (M2).
|
||||
|
||||
extract (cached) -> graph -> metrics -> scoring -> local artifacts -> ES index.
|
||||
|
||||
python build.py --institution-id I62318514 # full run
|
||||
python build.py --institution-id I62318514 --force-extract # refresh the ES extract
|
||||
python build.py --institution-id I62318514 --no-index # skip the ES write
|
||||
|
||||
Artifacts in --cache-dir:
|
||||
authors_<ID>.jsonl.gz / works_<ID>.jsonl.gz the extract (reused unless --force-extract)
|
||||
scores_<ID>.jsonl.gz one scored row per focal author
|
||||
build_summary_<ID>.json stage timings + tag counts + top lists
|
||||
|
||||
The ES write targets `multiplicators_v1` on the INSE cluster (admin-created; the API
|
||||
key cannot create indices). Doc _id = <institution>_<author>; every run deletes the
|
||||
institution's docs first, so re-runs are idempotent.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from extract import extract_to_cache, read_jsonl_gz
|
||||
from graph import build_graph, short_id
|
||||
from index import NETWORK_MAPPING, NETWORKS_INDEX, MultiplicatorsIndexClient
|
||||
from metrics import compute_all_metrics, incident_edges
|
||||
from networks import build_network_docs
|
||||
from scoring import load_config, score_rows
|
||||
from signals import collect_signals, normalize_doi
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--institution-id", required=True)
|
||||
parser.add_argument("--config", default=str(SCRIPT_DIR / "multipliers.yaml"))
|
||||
parser.add_argument("--cache-dir", default=str(SCRIPT_DIR / "cache"))
|
||||
parser.add_argument(
|
||||
"--force-extract", action="store_true",
|
||||
help="Re-extract from ES even if a cache exists.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-index", action="store_true",
|
||||
help="Compute and write local artifacts but skip the ES indexing step.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-signals", action="store_true",
|
||||
help="Skip the patents/news/CORDIS signal joins (amplifier falls back to "
|
||||
"industry co-authorship alone).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-network", action="store_true",
|
||||
help="Skip materializing the per-author ego-network visualization docs.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
short = args.institution_id.strip().rsplit("/", 1)[-1]
|
||||
cache_dir = Path(args.cache_dir)
|
||||
config = load_config(args.config)
|
||||
timings: dict[str, float] = {}
|
||||
|
||||
# ---- extract (cache-aware) ----
|
||||
t0 = time.time()
|
||||
authors_path, works_path, insts = extract_to_cache(
|
||||
args.institution_id, config, cache_dir, force=args.force_extract
|
||||
)
|
||||
cohort_short_ids = [i["short_id"] for i in insts]
|
||||
timings["extract_s"] = round(time.time() - t0, 1)
|
||||
|
||||
# ---- load ----
|
||||
t0 = time.time()
|
||||
focal_ids = {a["id"] for a in read_jsonl_gz(authors_path)}
|
||||
works = list(read_jsonl_gz(works_path))
|
||||
timings["load_cache_s"] = round(time.time() - t0, 1)
|
||||
print(f"Loaded {len(works)} works, {len(focal_ids)} focal authors "
|
||||
f"({timings['load_cache_s']}s)")
|
||||
|
||||
# ---- single pass over works before they are freed: DOIs per focal author
|
||||
# (CORDIS join), per-author institution counts (modal label), and per-WORK
|
||||
# company affiliations (tie-level industry roles in the network docs)
|
||||
focal_short_ids = {short_id(a) for a in focal_ids}
|
||||
max_authors = int(config["extraction"]["max_authors_per_work"])
|
||||
dois_by_author: dict[str, set[str]] = {}
|
||||
inst_counts: dict[str, dict[str, int]] = {}
|
||||
company_by_author_work: dict[str, dict[str, list[str]]] = {}
|
||||
company_work_authors: dict[str, set[str]] = {}
|
||||
for w in works:
|
||||
doi = normalize_doi(w.get("doi"))
|
||||
wid = short_id(w.get("id"))
|
||||
work_authors: set[str] = set()
|
||||
work_companies: dict[str, list[str]] = {}
|
||||
for a in w.get("authorships") or []:
|
||||
aid = short_id((a.get("author") or {}).get("id"))
|
||||
if not aid:
|
||||
continue
|
||||
work_authors.add(aid)
|
||||
if doi and aid in focal_short_ids:
|
||||
dois_by_author.setdefault(aid, set()).add(doi)
|
||||
for inst in a.get("institutions") or []:
|
||||
name = inst.get("display_name")
|
||||
if name:
|
||||
counts = inst_counts.setdefault(aid, {})
|
||||
counts[name] = counts.get(name, 0) + 1
|
||||
if inst.get("type") == "company":
|
||||
work_companies.setdefault(aid, []).append(name)
|
||||
# company evidence only for works that also enter the graph (same cap)
|
||||
if wid and work_companies and 2 <= len(work_authors) <= max_authors:
|
||||
company_work_authors[wid] = work_authors
|
||||
for aid, names in work_companies.items():
|
||||
company_by_author_work.setdefault(aid, {})[wid] = names
|
||||
inst_by_author = {
|
||||
aid: max(counts, key=counts.get) for aid, counts in inst_counts.items()
|
||||
}
|
||||
del inst_counts
|
||||
|
||||
# ---- graph ----
|
||||
t0 = time.time()
|
||||
graph = build_graph(
|
||||
works,
|
||||
focal_ids,
|
||||
max_authors_per_work=config["extraction"]["max_authors_per_work"],
|
||||
decay=config["graph"]["decay"],
|
||||
)
|
||||
del works
|
||||
timings["build_graph_s"] = round(time.time() - t0, 1)
|
||||
print(f"Graph: {len(graph.nodes)} nodes, {len(graph.edges)} edges, "
|
||||
f"{graph.n_works_used} works used, {graph.n_works_capped} capped, "
|
||||
f"ref_year={graph.ref_year} ({timings['build_graph_s']}s)")
|
||||
|
||||
# ---- metrics ----
|
||||
t0 = time.time()
|
||||
metric_rows = compute_all_metrics(
|
||||
graph,
|
||||
junior_active_years_max=config["mentor"]["junior_active_years_max"],
|
||||
senior_active_years_min=config["mentor"]["senior_active_years_min"],
|
||||
progressed_active_years_min=config["mentor"]["progressed_active_years_min"],
|
||||
industry_share_shrinkage_k=config.get("signals", {}).get(
|
||||
"industry_share_shrinkage_k", 5
|
||||
),
|
||||
)
|
||||
timings["metrics_s"] = round(time.time() - t0, 1)
|
||||
print(f"Metrics for {len(metric_rows)} focal authors ({timings['metrics_s']}s)")
|
||||
|
||||
# ---- signal joins (patents / news / CORDIS) ----
|
||||
if args.no_signals:
|
||||
print("Skipping signal joins (--no-signals).")
|
||||
timings["signals_s"] = 0.0
|
||||
else:
|
||||
t0 = time.time()
|
||||
signals_cfg = config.get("signals") or {}
|
||||
display_names = {
|
||||
aid: row.get("display_name") or "" for aid, row in metric_rows.items()
|
||||
}
|
||||
signal_counts = collect_signals(
|
||||
short,
|
||||
display_names,
|
||||
{a: d for a, d in dois_by_author.items() if a in metric_rows},
|
||||
scored_match_types=tuple(
|
||||
signals_cfg.get("patent_match_types", ["institution", "both"])
|
||||
),
|
||||
news_require_relevant=signals_cfg.get("news_require_relevant", True),
|
||||
)
|
||||
for metric, counts in signal_counts.items():
|
||||
for aid, row in metric_rows.items():
|
||||
row[metric] = counts.get(aid, 0)
|
||||
timings["signals_s"] = round(time.time() - t0, 1)
|
||||
print(f"Signal joins done ({timings['signals_s']}s)")
|
||||
|
||||
# ---- scoring ----
|
||||
t0 = time.time()
|
||||
scored = score_rows(metric_rows, config)
|
||||
timings["scoring_s"] = round(time.time() - t0, 1)
|
||||
|
||||
scores_path = cache_dir / f"scores_{short}.jsonl.gz"
|
||||
with gzip.open(scores_path, "wt", encoding="utf-8", newline="\n") as f:
|
||||
for row in scored:
|
||||
f.write(json.dumps(row, ensure_ascii=True) + "\n")
|
||||
print(f"Scores -> {scores_path} ({timings['scoring_s']}s)")
|
||||
|
||||
# ---- index into ES ----
|
||||
docs_written = 0
|
||||
if args.no_index:
|
||||
print("Skipping ES indexing (--no-index).")
|
||||
else:
|
||||
t0 = time.time()
|
||||
es = MultiplicatorsIndexClient()
|
||||
es.ensure_mapping()
|
||||
docs_written = es.index_rows(short, cohort_short_ids, scored)
|
||||
count = es.count_for_institution(short)
|
||||
timings["index_s"] = round(time.time() - t0, 1)
|
||||
print(f"Indexed {docs_written} docs into {es.index} "
|
||||
f"(count for {short}: {count}) ({timings['index_s']}s)")
|
||||
if count != len(scored):
|
||||
raise RuntimeError(
|
||||
f"Post-index count mismatch: expected {len(scored)}, index has {count}"
|
||||
)
|
||||
|
||||
# ---- ego-network visualization docs ----
|
||||
network_docs_written = 0
|
||||
if args.no_index or args.no_network:
|
||||
print("Skipping network materialization.")
|
||||
else:
|
||||
t0 = time.time()
|
||||
network_cfg = config.get("network") or {}
|
||||
network_docs = build_network_docs(
|
||||
graph,
|
||||
metric_rows,
|
||||
scored,
|
||||
incident_edges(graph),
|
||||
inst_by_author,
|
||||
company_by_author_work,
|
||||
company_work_authors,
|
||||
max_nodes=int(network_cfg.get("max_nodes", 42)),
|
||||
max_forced_mentees=int(network_cfg.get("max_forced_mentees", 14)),
|
||||
)
|
||||
net_es = MultiplicatorsIndexClient(index=NETWORKS_INDEX)
|
||||
net_es.ensure_mapping(NETWORK_MAPPING)
|
||||
network_docs_written = net_es.index_rows(short, cohort_short_ids, network_docs)
|
||||
timings["network_s"] = round(time.time() - t0, 1)
|
||||
print(f"Indexed {network_docs_written} network docs into {net_es.index} "
|
||||
f"({timings['network_s']}s)")
|
||||
|
||||
# ---- summary ----
|
||||
tag_counts: dict[str, int] = {}
|
||||
for row in scored:
|
||||
for tag in row["tags"]:
|
||||
tag_counts[tag] = tag_counts.get(tag, 0) + 1
|
||||
|
||||
def top(sub: str, k: int = 10):
|
||||
rows = sorted(scored, key=lambda r: r["sub_scores"].get(sub, 0), reverse=True)
|
||||
return [
|
||||
{
|
||||
"author_id": r["author_id"],
|
||||
"name": r["display_name"],
|
||||
"score": r["sub_scores"][sub],
|
||||
"bucket": r["career_bucket"],
|
||||
"active_years": r["active_years"],
|
||||
"suspicious": r["suspicious_profile"],
|
||||
}
|
||||
for r in rows[:k]
|
||||
]
|
||||
|
||||
summary = {
|
||||
"institution": short,
|
||||
"cohort": cohort_short_ids,
|
||||
"config_hash": config["_config_hash"],
|
||||
"counts": {
|
||||
"focal_authors_scored": len(scored),
|
||||
"nodes": len(graph.nodes),
|
||||
"edges": len(graph.edges),
|
||||
"works_used": graph.n_works_used,
|
||||
"works_capped": graph.n_works_capped,
|
||||
"tags": tag_counts,
|
||||
"suspicious_profiles": sum(1 for r in scored if r["suspicious_profile"]),
|
||||
"es_docs_written": docs_written,
|
||||
"es_network_docs_written": network_docs_written,
|
||||
},
|
||||
"timings": timings,
|
||||
"top_bridgers": top("bridger"),
|
||||
"top_mentors": top("mentor"),
|
||||
"top_amplifiers": top("amplifier"),
|
||||
}
|
||||
summary_path = cache_dir / f"build_summary_{short}.json"
|
||||
with open(summary_path, "w", encoding="utf-8", newline="\n") as f:
|
||||
json.dump(summary, f, ensure_ascii=False, indent=2)
|
||||
print(json.dumps(summary["counts"], ensure_ascii=False, indent=2))
|
||||
print(f"Summary -> {summary_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,5 +0,0 @@
|
||||
"""Make the module root importable from tests/ (pytest inserts this dir via conftest)."""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
@@ -1,116 +0,0 @@
|
||||
# Cohort discovery: finding a university's associated institutions in OpenAlex
|
||||
|
||||
How the `cohorts.<ID>.institution_ids` list in `multipliers.yaml` was built for the
|
||||
University of Duisburg-Essen (I62318514), and how to repeat the process for another
|
||||
university. Context: the multiplicator pipeline's author set is only as good as this
|
||||
list — matching UDE alone silently excluded ~2,400 active clinicians, including
|
||||
prominent medicine professors (found via the M1 validation, where 17/60 hand-labeled
|
||||
people were missing).
|
||||
|
||||
## Why this is necessary: `lineage` vs `associated_institutions`
|
||||
|
||||
Every institution document in OpenAlex (index `openalex-institutions`) carries two
|
||||
relationship fields:
|
||||
|
||||
- **`lineage`** — the strict parent hierarchy: a list of institution IDs including the
|
||||
institution itself and its parents. This is what ID-based filters normally use
|
||||
(e.g. `company_connections/logic.py` checks `UDE_OPENALEX_ID in lineage`).
|
||||
- **`associated_institutions`** — a looser list of linked institutions, each with a
|
||||
`relationship` label: `child`, `parent`, or `related`.
|
||||
|
||||
The trap: **OpenAlex models German university hospitals as `related`, not as lineage
|
||||
children.** Essen University Hospital's own `lineage` contains only itself. Any filter
|
||||
built on UDE's ID or lineage therefore can never match hospital-affiliated authors —
|
||||
the entire clinical medical faculty — no matter how the query is written.
|
||||
|
||||
## The discovery method (3 steps)
|
||||
|
||||
### Step 1 — read the university's `associated_institutions`
|
||||
|
||||
Query the `openalex-institutions` document for the primary ID and list its
|
||||
`associated_institutions`. For UDE (I62318514):
|
||||
|
||||
| ID | relationship | name | authors (all-time last_known) |
|
||||
|---|---|---|---|
|
||||
| I4210090139 | child | Rhein-Ruhr Institut für Sozialforschung | 11 |
|
||||
| I4210092428 | child | Deutsches Textilforschungszentrum Nord-West | 170 |
|
||||
| I4210110714 | child | Institute for Advanced Study in the Humanities (KWI) | 81 |
|
||||
| I4210146441 | child | Hydrogen and Fuel Cell Center (ZBT) | 98 |
|
||||
| I4210154243 | child | Institut für Energie- und Umwelttechnik (IUTA) | 233 |
|
||||
| **I4210119759** | **related** | **Essen University Hospital** | **7,484** |
|
||||
| I4210146447 | related | Kliniken Essen-Mitte | 788 |
|
||||
| I2799342142 | related | Salomon Ludwig Steinheim-Institut | — |
|
||||
| I4210124583 | related | IWW Water Centre | — |
|
||||
|
||||
(For comparison: UDE itself has 14,388 all-time last_known authors.)
|
||||
|
||||
### Step 2 — follow one hop into any `related` hospital
|
||||
|
||||
The hospital's own `associated_institutions` revealed a member invisible from UDE's
|
||||
record: the **West German Heart and Vascular Center Essen (I4210161917)** is a `child`
|
||||
of the hospital (1,021 authors) — two hops from UDE.
|
||||
|
||||
### Step 3 — validate against real people (this catches what no query can)
|
||||
|
||||
The **Erwin L. Hahn Institute for MRI (I127668822)** was NOT found by any metadata
|
||||
walk: in OpenAlex it is completely isolated — `lineage` contains only itself,
|
||||
`associated_institutions` is empty. It surfaced only when diagnosing why a specific
|
||||
hand-labeled professor (Ulrike Bingel) was missing from the cohort: it appeared in her
|
||||
affiliation list. Lesson: after building the list from metadata, always check a set of
|
||||
known current researchers against the extracted cohort — the misses point to
|
||||
institutions the graph walk cannot reach.
|
||||
|
||||
## Inclusion decisions for UDE (documented in `multipliers.yaml`)
|
||||
|
||||
**Included (9):**
|
||||
|
||||
- `I62318514` UDE (primary)
|
||||
- `I4210119759` Essen University Hospital — it *is* the university medical centre;
|
||||
its `related` label is an OpenAlex modelling choice, not an organisational fact
|
||||
- `I4210161917` West German Heart and Vascular Center (child of the hospital)
|
||||
- `I127668822` Erwin L. Hahn Institute (joint UDE institute; isolated in OpenAlex)
|
||||
- The five lineage children: RISP, DTNW, KWI, ZBT, IUTA — small but unambiguous
|
||||
|
||||
**Excluded by default (revisit with the coaches):**
|
||||
|
||||
- `I4210146447` Kliniken Essen-Mitte — an independent hospital group; `related`
|
||||
reflects collaboration, not membership; its staff are not UDE researchers
|
||||
- `I2799342142` Salomon Ludwig Steinheim-Institut and `I4210124583` IWW Water
|
||||
Centre — *An-Institute*: legally independent institutes **at** UDE, not **of** it
|
||||
|
||||
The borderline cases are exactly the German-institutional-law ones (An-Institute,
|
||||
municipal hospital groups). These are human judgment calls, which is why the list
|
||||
lives in config with the reasoning inline, not in code.
|
||||
|
||||
## Effect on the cohort (measured)
|
||||
|
||||
| | UDE ID only | 9-institution cohort |
|
||||
|---|---|---|
|
||||
| Authors (affiliation ≥ 2023) | ~7,100¹ | 9,475 |
|
||||
| Hand-labeled sample matched | 43/60² | 51/60 |
|
||||
| Unexplained misses | 17 | **0** (the 9 remaining all verifiably left UDE) |
|
||||
|
||||
¹ approximate — the single-ID number was measured at the 2025 cutoff (4,921); scaled here for context.
|
||||
² at the 2025 cutoff; the cohort fix and the 2023 affiliation window each contributed.
|
||||
|
||||
Recovered by the fix, as a face-validity check: Oliver Witzke (Senior, 73 juniors
|
||||
mentored → tagged mentor) and Ulrike Bingel (Senior, 34 juniors, 21
|
||||
last-author-with-junior-first works → tagged mentor).
|
||||
|
||||
## Repeating this for another university
|
||||
|
||||
1. Fetch `associated_institutions` from `openalex-institutions` for the primary ID;
|
||||
collect all `child` entries and every `related` entry.
|
||||
2. For any `related` hospital / medical centre, fetch ITS `associated_institutions`
|
||||
and collect its children.
|
||||
3. For each candidate, count authors
|
||||
(`last_known_institutions.id == <candidate>` on `openalex-authors`) — size tells
|
||||
you what an inclusion decision is worth.
|
||||
4. Decide inclusions with a human: university hospitals in; independent hospital
|
||||
groups and An-Institute out unless the institution says otherwise.
|
||||
5. Write the `cohorts.<primary-ID>` block in `multipliers.yaml` with the reasoning
|
||||
as inline comments.
|
||||
6. Run the extraction, then validate against a list of known current researchers
|
||||
(professors from several faculties, especially medicine). Every unexplained miss
|
||||
is either a missing cohort member (like the Hahn Institute) or a stale-affiliation
|
||||
case (tune `extraction.affiliation_years_gte`).
|
||||
@@ -1,239 +0,0 @@
|
||||
# Multiplicator Detection — Concept, Technical Walkthrough & Roadmap
|
||||
|
||||
A ground-up explanation of what this module does, how every field in the
|
||||
`multiplicators_v1` index is computed and what it means, where the ideas come from,
|
||||
and where the project stands. Written for a reader with no prior context.
|
||||
|
||||
Companion docs: [README.md](../README.md) (per-milestone results and stats),
|
||||
[ASSOCIATED_INSTITUTIONS.md](ASSOCIATED_INSTITUTIONS.md) (cohort discovery method).
|
||||
|
||||
---
|
||||
|
||||
## 1. What problem this solves
|
||||
|
||||
The university's innovation coaches want to find **multiplicators**: people whose value
|
||||
isn't only their own research output, but their effect on the system around them — they
|
||||
connect groups that otherwise wouldn't talk, they grow junior researchers into
|
||||
independent scientists, they carry research out of academia into industry and the
|
||||
public. These people are invisible in classic rankings (citations, h-index), which
|
||||
measure individual output, not systemic effect.
|
||||
|
||||
The core bet of the whole project: **these behaviors leave measurable traces in
|
||||
publication metadata.** Who you publish with, when, in what role, and across which
|
||||
institutional boundaries is recorded in OpenAlex for every paper. So instead of asking
|
||||
"who is influential?" we ask three narrower, checkable questions, each an archetype:
|
||||
|
||||
- **Bridger** — do your collaborations span otherwise-disconnected communities,
|
||||
fields, institutions, sectors?
|
||||
- **Mentor** — do junior people repeatedly start their careers publishing with you,
|
||||
in the role configuration typical of supervision?
|
||||
- **Amplifier** — does your work escape academia: patents, industry co-authorship,
|
||||
EU projects, press coverage?
|
||||
|
||||
Everything else is machinery for answering those three questions honestly at the
|
||||
scale of ~9,500 people.
|
||||
|
||||
## 2. The pipeline, step by step
|
||||
|
||||
**Step 1 — Define who "the university" is (cohort).** OpenAlex models Essen University
|
||||
Hospital as merely *related* to UDE, not part of it, so filtering by UDE's ID alone
|
||||
silently loses the entire clinical faculty (~2,400 active people). The cohort is
|
||||
therefore an explicit list of 9 institution IDs (UDE + hospital + heart center +
|
||||
affiliated institutes) — the `cohort_institution_ids` array on every document. An
|
||||
author belongs if their last-known institution is in that list **and** they have an
|
||||
affiliation year ≥ 2023 (publication lag makes a 1-year window drop current staff).
|
||||
Details: [ASSOCIATED_INSTITUTIONS.md](ASSOCIATED_INSTITUTIONS.md).
|
||||
|
||||
**Step 2 — Extract.** For those ~9,475 authors we pull **all their works globally** —
|
||||
not just university-affiliated ones — with the *complete* author list of every paper,
|
||||
including external co-authors and each co-author's institution (with its type:
|
||||
education, company, healthcare…). Result: ~267k works, ~3.8M authorship records.
|
||||
The "all works globally" property matters: it makes career histories *exact* for
|
||||
cohort members, while external co-authors' histories are truncated to shared works —
|
||||
a fact the mentor metrics must respect (see §3).
|
||||
|
||||
**Step 3 — Build the co-authorship graph.** Every paper connects each pair of its
|
||||
authors with an edge. Three refinements:
|
||||
|
||||
- **Team-size weighting**: a pair on a 3-author paper gets weight 1/(n−1) = 0.5; on a
|
||||
40-author paper, 1/39. Being 2 of 3 authors is strong evidence you actually work
|
||||
together; being 2 of 40 is weak evidence.
|
||||
- **Time decay**: each paper's contribution is multiplied by 0.8^(years ago). A 2025
|
||||
collaboration counts full; a 2010 one counts ~3%. We're looking for *current*
|
||||
multiplicators.
|
||||
- **Hyperauthorship cap**: papers with >50 authors (CERN-style consortia; the corpus
|
||||
max is 4,839 authors on one paper) are excluded from the graph entirely — that one
|
||||
paper alone would create ~11.7M fake "collaboration" edges and a giant artificial
|
||||
clique. Those papers still count for career metrics.
|
||||
|
||||
Result: ~865k nodes (cohort + all their external co-authors), ~5.8M weighted edges.
|
||||
|
||||
**Step 4 — Compute metrics on that graph** (§3, field by field).
|
||||
|
||||
**Step 5 — Normalize fairly and score.** Raw metrics aren't comparable between a PhD
|
||||
student and a 30-year professor, so every metric becomes a **percentile within the
|
||||
person's career stage**, then three weighted sub-scores, then tags above a threshold
|
||||
(§4).
|
||||
|
||||
**Step 6 — Join external signals** (patents, news, EU projects) and **write everything
|
||||
to `multiplicators_v1`** — one document per person, containing raw values, percentiles,
|
||||
scores, tags, and evidence, so a coach can always see *why* someone scored what they
|
||||
scored.
|
||||
|
||||
## 3. A real document, field by field
|
||||
|
||||
Example: Tabea M. G. Pakull, `_id = I62318514_A5043360678` (institution + author —
|
||||
the same person at another university would be a separate doc). An ES `_version: 8`
|
||||
just means the doc was overwritten 8 times by re-runs; the `fields` block ES returns
|
||||
alongside `_source` is its internal columnar echo — ignore it.
|
||||
|
||||
### Career context
|
||||
|
||||
| field | example value | meaning |
|
||||
|---|---|---|
|
||||
| `active_years` | 3 | Distinct calendar years with ≥1 publication — our seniority measure. We deliberately do **not** use "years since first publication": the repo's career-stage analysis found merged OpenAlex profiles give active professors debut years like 1893. One wrong old paper distorts career span by decades but moves `active_years` by exactly +1. |
|
||||
| `career_bucket` | "Early" | Early ≤4, Emerging ≤9, Established ≤14, Senior >14 active years — thresholds taken unchanged from the backend's `_classify_career_stage`, empirically validated against 60 known professors/researchers. **All percentiles are computed against the same bucket only.** |
|
||||
| `n_works` | 12 | Works in the extract. |
|
||||
| `suspicious_profile` | false | Merged-identity flag (first year <1970 or span >60). True ⇒ treat evidence as low-confidence; ~18% of Seniors carry it. |
|
||||
|
||||
### Bridger metrics (network structure)
|
||||
|
||||
| field | example | what it measures |
|
||||
|---|---|---|
|
||||
| `betweenness` | 0 | **Betweenness centrality** on the cohort-internal graph: how often the strongest connection paths between other cohort members run *through you*. High = the network's traffic must pass you = you connect groups. Edge weights are "closeness", so paths use inverted weights as distances. A 0 is normal early-career; the percentile can still be ~0.44 because most of the bucket is also 0 and ties share their average rank. |
|
||||
| `constraint` → `brokerage` | 0.085 → 0.915 | **Burt's constraint** looks only at your *ego network* (you + your co-authors): do your contacts also know each other? High constraint = you sit inside one dense clique. Low = your contacts live in separate worlds and *you* are the only link — you span "structural holes". Stored as `brokerage = 1 − constraint` so higher = more bridging. Computed on the **full graph including external co-authors**, so it sees outward bridging that internal betweenness can't. In the example: 82 co-authors who barely know each other — 90th percentile of the Early bucket. |
|
||||
| `field_entropy` | 0.98 | Shannon entropy over the scientific fields of the person's papers. 0 = monodisciplinary; 1.0 bit ≈ two fields evenly; 2.0 ≈ four. Topical breadth as a proxy for interdisciplinary bridging (OpenAlex has no faculty structure, so this is the honest substitute — it must never be presented as "bridges faculties"). |
|
||||
| `cross_institution_share` | 0.85 | Share of collaboration weight with co-authors sharing *no* institution with the person — external orientation. |
|
||||
| `strength`, `n_coauthors` | 8.25, 82 | Total decayed edge weight and distinct co-author count — "reach", context only, not scored directly. |
|
||||
|
||||
### Mentor metrics
|
||||
|
||||
OpenAlex has no supervision records and debut years are unreliable, so the mentor
|
||||
signals are built on **`active_years_at(person, year)`** — how many active years
|
||||
someone had accumulated *as of a given year* — which inherits the robustness of
|
||||
`active_years` (a spurious 1893 paper shifts it by exactly 1, not 120).
|
||||
|
||||
| field | definition |
|
||||
|---|---|
|
||||
| `juniors_mentored` | Count of cohort co-authors who, in the year of their *first* joint paper, had ≤4 active years (Early) **while the focal person had ≥10** (Established+). A seniority-*gap* criterion — two PhD students co-publishing never counts. |
|
||||
| `junior_progression_rate` | Of those juniors, the fraction who later reached ≥5 active years — separates "grew them up" from "co-signed once". `null` = no juniors = not applicable (excluded from scoring, not counted against the person). |
|
||||
| `last_author_with_junior_first` | Papers where the person is **last author** with an Early-career **first author** — the classic supervision signature (student first, PI last). Deliberately independent of the gap logic: when the two disagree (37 "juniors" but zero last-author papers) that's the core-facility-scientist pattern, not a mentor. |
|
||||
| `mentoring_rate` | juniors ÷ own active years. Without a rate, prolific seniors win on volume alone (professor median 224 papers vs 11 for researchers). |
|
||||
|
||||
Mentor metrics are computed **only between cohort members**: external co-authors'
|
||||
histories are truncated to shared works, so an external senior would masquerade as a
|
||||
junior. This scope restriction is a data-correctness requirement, not a choice.
|
||||
|
||||
### Amplifier metrics
|
||||
|
||||
| field | source & link quality |
|
||||
|---|---|
|
||||
| `industry_coauthor_share` | Share of typed works with ≥1 company-affiliated co-author. The strongest industry signal available because it's **institution-ID-linked** — no name matching. Kept raw for transparency. |
|
||||
| `industry_coauthor_share_shrunk` | The **scored** variant: company ÷ (typed + 5). Why: with raw shares, someone with 2-of-2 company papers gets share 1.0 and beats someone with 40-of-80 — before this fix, the index's entire top-10 "amplifiers" were such small-denominator artifacts. The +5 makes small samples humble. |
|
||||
| `patent_count` | From `org_patents`, which links patents to OpenAlex author IDs. Only high-confidence matches (`match_type` = institution/both) are scored. |
|
||||
| `patent_count_name_only` | Name-only patent matches — **evidence only, never scored**. |
|
||||
| `news_mentions` | University press corpus, LLM-extracted names, matched after normalizing case and diacritics (René = rene). If a normalized name belongs to *two* cohort people, **nobody** gets credit (839 names skipped at UDE) — miscrediting is worse than missing. Hence the low weight. |
|
||||
| `cordis_eu_projects` | Distinct EU projects joined by **DOI overlap** (the person's paper DOIs ∩ DOIs attached to CORDIS project publications) — no name matching. Matching is case-insensitive because 21% of CORDIS DOIs contain uppercase. |
|
||||
|
||||
### Scoring plumbing
|
||||
|
||||
| field | meaning |
|
||||
|---|---|
|
||||
| `percentiles.*` | Each raw metric's mean-rank percentile *within the career bucket*. Ties share their average rank — that's why a metric at 0 in a mostly-zero bucket shows ~0.44–0.50, not 1.0: a mass of zeros must not be rewarded. `null` metrics are excluded, and their weight is redistributed. |
|
||||
| `sub_scores.{bridger,mentor,amplifier}` | Weighted means of the percentiles. Weights live in `multipliers.yaml`, never in code — coaches retune them. Current amplifier weights: shrunk share 0.50, patents 0.25, CORDIS 0.15, news 0.10. |
|
||||
| `tags` | Sub-score ≥ `tags.threshold` (0.85) ⇒ tag; a person can hold 0–3. Current yield at UDE: 133 bridgers, 161 mentors, 10 amplifiers. |
|
||||
| `max_sub_score` | Best sub-score — the default ranking key. |
|
||||
| `evidence.junior_ids` | Receipts (which people count as mentees) — a coach never sees a bare number. |
|
||||
| `config_hash`, `computed_at` | Which YAML weighting produced the score, and when. Scores are cohort-relative and weight-dependent; without this they'd be unfalsifiable after the next retune. |
|
||||
| `institution_id`, `cohort_institution_ids` | Which university this doc belongs to and which 9 institutions defined its cohort. |
|
||||
|
||||
Worked example (the Pakull doc): amplifier = 0.50·0.99 (shrunk share) + 0.25·0.50
|
||||
(patents, tie-mass) + 0.15·0.98 (one EU project — 98th percentile *for an
|
||||
Early-career person*) + 0.10·0.47 (news) = **0.8131** — high, but under 0.85 ⇒ no
|
||||
tag. Mentor 0.494 ≈ bucket median: all-zero mentor metrics in a bucket where nearly
|
||||
everyone is zero lands exactly mid-pack.
|
||||
|
||||
## 4. related work
|
||||
|
||||
- **Co-authorship graphs as collaboration networks** — Mark Newman's early-2000s
|
||||
studies of scientific collaboration networks, which also introduced the 1/(n−1)
|
||||
team-size weighting. The warning that huge author lists break co-authorship
|
||||
semantics is Blaise Cronin's "hyperauthorship" critique — the basis for the
|
||||
50-author cap.
|
||||
- **Bridger, theory** — Granovetter's "strength of weak ties" (1973): novel
|
||||
information flows across bridges between groups, not within dense cliques.
|
||||
- **Bridger, operationalization** — *betweenness centrality* (Linton Freeman, 1977),
|
||||
computed with Ulrik Brandes' 2001 algorithm (implemented in `metrics.py`, tested
|
||||
against networkx); *structural holes and constraint* (Ronald Burt, 1992; his 2004
|
||||
"Structural holes and good ideas" showed brokers produce more good ideas). The
|
||||
weights-are-distances inversion for betweenness is a standard weighted-network
|
||||
practice. Shannon entropy as a diversity/interdisciplinarity indicator follows
|
||||
standard scientometrics usage (Stirling-style diversity).
|
||||
- **Mentor** — reading mentorship from publication genealogies is established in
|
||||
scientometrics (e.g. Malmgren, Ottino & Amaral's Nature study of mentor–protégé
|
||||
networks). The first-author-student / last-author-PI convention is a documented
|
||||
authorship norm in the life sciences — credible at a medicine-heavy university.
|
||||
Shipped caveat: co-authorship ≠ supervision; it's a proxy, validated directionally
|
||||
against 60 hand-labeled people (professors' median mentor score 0.740 vs
|
||||
researchers' 0.494).
|
||||
- **Amplifier** — the university "third mission" / knowledge-transfer literature
|
||||
(Etzkowitz & Leydesdorff's Triple Helix line): patents, industry co-publication,
|
||||
joint projects as measurable transfer channels. Industry co-authorship as primary
|
||||
indicator is pragmatic: it's the only channel linked by institution IDs rather
|
||||
than names.
|
||||
- **Fair comparison** — percentile indicators within reference groups are the modern
|
||||
bibliometrics standard (compare like with like). Our reference group is the career
|
||||
bucket; the buckets come from this repo's own `analysis/career_stage/` work, which
|
||||
is also the empirical source for the most important design decision: rejecting
|
||||
`first_publication_year` in favor of `active_years`. `active_years_at(A, Y)` is our
|
||||
small extension of that finding.
|
||||
- **Data-quality corrections** (all found by measuring, not assumed): the hospital
|
||||
cohort gap (OpenAlex `related` vs lineage), ratio shrinkage, tie-sharing
|
||||
percentiles, the news ambiguity rule, merged/split-profile flags — responses to
|
||||
the well-known author-disambiguation weaknesses of bibliographic databases.
|
||||
|
||||
## 5. What was achieved (status)
|
||||
|
||||
Three falsifiable behavioral definitions instead of a vague label; a decay- and
|
||||
team-size-weighted collaboration graph over the complete global publication history
|
||||
of a correctly-defined 9-institution cohort; established network-science and
|
||||
bibliometric measures, made robust against the two dominant data pathologies (merged
|
||||
profiles, hyperauthorship); within-career-stage normalization; three independent
|
||||
external evidence channels joined at their honest link quality; and a queryable index
|
||||
where every person carries raw values, percentiles, scores, tags, and receipts —
|
||||
validated against hand-labeled ground truth, every tunable in config, every score
|
||||
stamped with the config that produced it.
|
||||
|
||||
| Milestone | Status |
|
||||
|---|---|
|
||||
| M0 — de-risking spike against the real cluster | ✅ done |
|
||||
| M1 — graph + metrics + scoring core, 60-person validation | ✅ done (PASS) |
|
||||
| M2 — cohort fix, extraction module, idempotent `multiplicators_v1` indexing | ✅ done |
|
||||
| M3 — amplifier signal joins (patents / news / CORDIS) + shrinkage fix | ✅ wired & indexed |
|
||||
|
||||
## 6. Roadmap — what's next
|
||||
|
||||
1. **M3 calibration session (human, next).** Coaches provide a golden set of 10–20
|
||||
known multiplicators, ideally labeled by type. Tune `multipliers.yaml`
|
||||
(sub-score weights, per-tag thresholds — 0.85 currently yields 133/161/10
|
||||
bridger/mentor/amplifier tags; if more amplifier candidates are wanted, introduce
|
||||
per-tag thresholds). Re-run `validate_sample.py` after every change as regression.
|
||||
2. **M4 — read-only serving layer**, once the UI needs it: thin FastAPI router in
|
||||
`inse/multiplicators/` over BOTH indices — `multiplicators_v1` for list views
|
||||
(by tag/bucket/score + per-person evidence) and `multiplicator_networks_v1` for
|
||||
the ego-network visualization (one doc per author: nodes with roles, edges with
|
||||
tie strength/cross-institution flags, ego header — render with echarts force
|
||||
layout; see README "Network visualization index"). Then
|
||||
`./gradlew :service:exportOpenApiSpec` to regenerate the Angular client.
|
||||
3. **Scheduling** — re-run `build.py` per dump refresh (Airflow, like the other
|
||||
crawlers); scores are batch-computed, serving is read-only.
|
||||
4. **Deferred improvements**, in value order:
|
||||
- **ORCID / `ude_persons_1.0` bridge** — the single highest-value follow-up: fixes
|
||||
news linking, catches *split* profiles (the `suspicious_profile` flag only
|
||||
catches merges; one split-profile artifact sits in the current amplifier
|
||||
top-10), and would enable faculty-level bridging via the staff directory.
|
||||
- Per-field percentile cohorts (biologist baselines ≠ sociologist baselines) —
|
||||
decide with coaches.
|
||||
- Project layer as graph edges (consortium co-membership), DFG/Bund signals if a
|
||||
real person-link ever exists.
|
||||
- Committing the module (currently untracked on `feature/find-multipliers`).
|
||||
@@ -1,395 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
extract.py — cohort-aware extraction of the author + work sets from Elasticsearch.
|
||||
|
||||
Canonical home of the extraction logic (spike_audit.py and build.py both use it).
|
||||
|
||||
The author set is a UNION OF TWO QUERIES (a correctness requirement found during the
|
||||
seed audit — group 2 recovers ~4% of authors that group 1 silently drops):
|
||||
|
||||
1. backend_compatible last_known_institutions in the cohort AND a recent
|
||||
cohort affiliation (years >= extraction.affiliation_years_gte)
|
||||
2. empty_last_known_recent recent cohort affiliation but NO last_known_institutions
|
||||
|
||||
The cohort is the list of OpenAlex institution IDs from `cohorts.<primary>.institution_ids`
|
||||
in multiplicators.yaml (falling back to the primary ID alone). This exists because
|
||||
OpenAlex does NOT model university hospitals as lineage children — matching only the
|
||||
primary institution excluded ~2,400 active UDE clinicians.
|
||||
|
||||
The work set is ALL works by those authors, globally (full authorship lists incl.
|
||||
external co-authors — required for the bridging signals), paginated with
|
||||
search_after over an id sort, batched ~250 author IDs per terms query.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import gzip
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterable, Iterator
|
||||
|
||||
import httpx
|
||||
import yaml
|
||||
from dotenv import load_dotenv
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
ENV_PATH = SCRIPT_DIR.parent.parent / "src" / "main" / "inse" / ".env"
|
||||
load_dotenv(dotenv_path=ENV_PATH)
|
||||
|
||||
NES_URL = (os.environ.get("ELASTICSEARCH_URL") or "").rstrip("/")
|
||||
NES_KEY = os.environ.get("ELASTICSEARCH_API_KEY") or ""
|
||||
INSE_URL = (os.environ.get("ELASTICSEARCH_INSE_URL") or "").rstrip("/")
|
||||
INSE_KEY = os.environ.get("ELASTICSEARCH_INSE_API_KEY") or ""
|
||||
|
||||
AUTHOR_PAGE_SIZE = 1000
|
||||
AUTHOR_BATCH_SIZE = 250
|
||||
WORK_PAGE_SIZE = 1000
|
||||
REQUEST_TIMEOUT = 180.0
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# ES helpers
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def _headers(api_key: str) -> dict[str, str]:
|
||||
return {
|
||||
"Authorization": f"ApiKey {api_key}",
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def es_request(
|
||||
client: httpx.Client,
|
||||
method: str,
|
||||
base_url: str,
|
||||
api_key: str,
|
||||
path: str,
|
||||
body: dict[str, Any] | None = None,
|
||||
) -> httpx.Response:
|
||||
url = f"{base_url}/{path.lstrip('/')}"
|
||||
return client.request(
|
||||
method, url, headers=_headers(api_key), json=body, timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
|
||||
|
||||
def es_search(
|
||||
client: httpx.Client, base_url: str, api_key: str, index: str, body: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
response = es_request(client, "POST", base_url, api_key, f"{index}/_search", body)
|
||||
if not response.is_success:
|
||||
raise RuntimeError(
|
||||
f"ES error {response.status_code} for {index}:\n{response.text[:1000]}"
|
||||
)
|
||||
return response.json()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Config / cohort
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def load_config(path: str | Path) -> dict[str, Any]:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return yaml.safe_load(f) or {}
|
||||
|
||||
|
||||
def cohort_ids_for(config: dict[str, Any], primary_short_id: str) -> list[str]:
|
||||
cohort = (config.get("cohorts") or {}).get(primary_short_id) or {}
|
||||
ids = cohort.get("institution_ids")
|
||||
return [str(i) for i in ids] if ids else [primary_short_id]
|
||||
|
||||
|
||||
def resolve_institution(client: httpx.Client, institution_id: str) -> dict[str, Any]:
|
||||
"""Look up ror + display_name from openalex-institutions."""
|
||||
short = institution_id.strip().rsplit("/", 1)[-1]
|
||||
full = f"https://openalex.org/{short}"
|
||||
result = es_search(
|
||||
client, NES_URL, NES_KEY, "openalex-institutions",
|
||||
{"size": 1, "query": {"term": {"id": full}}},
|
||||
)
|
||||
hits = result["hits"]["hits"]
|
||||
if not hits:
|
||||
raise SystemExit(f"Institution {full} not found in openalex-institutions.")
|
||||
source = hits[0]["_source"]
|
||||
return {
|
||||
"id": full,
|
||||
"short_id": short,
|
||||
"ror": source.get("ror"),
|
||||
"display_name": source.get("display_name"),
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Author queries
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def recent_affiliation_filter(
|
||||
insts: list[dict[str, Any]], year_gte: int
|
||||
) -> dict[str, Any]:
|
||||
"""Recent affiliation with ANY cohort institution (matched by id, ror as backup)."""
|
||||
ids = [i["id"] for i in insts]
|
||||
shoulds: list[dict[str, Any]] = [{"terms": {"affiliations.institution.id": ids}}]
|
||||
rors = [i["ror"] for i in insts if i.get("ror")]
|
||||
if rors:
|
||||
shoulds.append({"terms": {"affiliations.institution.ror": rors}})
|
||||
return {
|
||||
"nested": {
|
||||
"path": "affiliations",
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"bool": {"should": shoulds, "minimum_should_match": 1}},
|
||||
{"range": {"affiliations.years": {"gte": year_gte}}},
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def last_known_filter(insts: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
return {
|
||||
"nested": {
|
||||
"path": "last_known_institutions",
|
||||
"query": {
|
||||
"terms": {"last_known_institutions.id": [i["id"] for i in insts]}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def last_known_exists_filter() -> dict[str, Any]:
|
||||
return {
|
||||
"nested": {
|
||||
"path": "last_known_institutions",
|
||||
"query": {"exists": {"field": "last_known_institutions.display_name"}},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AUTHOR_SOURCE = [
|
||||
"id",
|
||||
"display_name",
|
||||
"orcid",
|
||||
"works_count",
|
||||
"cited_by_count",
|
||||
"last_known_institutions",
|
||||
"affiliations",
|
||||
]
|
||||
|
||||
|
||||
def collect_authors(
|
||||
client: httpx.Client,
|
||||
insts: list[dict[str, Any]],
|
||||
affiliation_year_gte: int,
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
groups = {
|
||||
"backend_compatible": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
last_known_filter(insts),
|
||||
recent_affiliation_filter(insts, affiliation_year_gte),
|
||||
]
|
||||
}
|
||||
},
|
||||
"empty_last_known_recent": {
|
||||
"bool": {
|
||||
"filter": [recent_affiliation_filter(insts, affiliation_year_gte)],
|
||||
"must_not": [last_known_exists_filter()],
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
authors: dict[str, dict[str, Any]] = {}
|
||||
for group_name, query in groups.items():
|
||||
search_after = None
|
||||
total = None
|
||||
read = 0
|
||||
while True:
|
||||
body: dict[str, Any] = {
|
||||
"size": AUTHOR_PAGE_SIZE,
|
||||
"track_total_hits": True,
|
||||
"_source": AUTHOR_SOURCE,
|
||||
"query": query,
|
||||
"sort": [{"id": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
result = es_search(client, NES_URL, NES_KEY, "openalex-authors", body)
|
||||
hits = result["hits"]["hits"]
|
||||
if total is None:
|
||||
total = result["hits"]["total"]["value"]
|
||||
print(f" [{group_name}] expected {total}")
|
||||
if not hits:
|
||||
break
|
||||
for hit in hits:
|
||||
src = hit["_source"]
|
||||
aid = src.get("id")
|
||||
if not aid:
|
||||
continue
|
||||
if aid not in authors:
|
||||
authors[aid] = {
|
||||
"id": aid,
|
||||
"display_name": src.get("display_name"),
|
||||
"orcid": src.get("orcid"),
|
||||
"works_count": src.get("works_count"),
|
||||
"cited_by_count": src.get("cited_by_count"),
|
||||
"source_sets": [group_name],
|
||||
}
|
||||
elif group_name not in authors[aid]["source_sets"]:
|
||||
authors[aid]["source_sets"].append(group_name)
|
||||
read += 1
|
||||
search_after = hits[-1]["sort"]
|
||||
print(f" [{group_name}] read {read}/{total}")
|
||||
time.sleep(0.05)
|
||||
return authors
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Work queries — FULL authorships, no inner_hits
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
WORK_SOURCE = [
|
||||
"id",
|
||||
"doi",
|
||||
"publication_year",
|
||||
"type",
|
||||
"cited_by_count",
|
||||
"primary_topic.id",
|
||||
"primary_topic.display_name",
|
||||
"primary_topic.field.id",
|
||||
"primary_topic.field.display_name",
|
||||
"authorships.author.id",
|
||||
"authorships.author.display_name",
|
||||
"authorships.author_position",
|
||||
"authorships.is_corresponding",
|
||||
"authorships.institutions.id",
|
||||
"authorships.institutions.display_name",
|
||||
"authorships.institutions.type",
|
||||
"authorships.institutions.country_code",
|
||||
"authorships.institutions.lineage",
|
||||
]
|
||||
|
||||
|
||||
def collect_works(
|
||||
client: httpx.Client, author_ids: list[str], work_year_gte: int
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
works: dict[str, dict[str, Any]] = {}
|
||||
total_batches = (len(author_ids) + AUTHOR_BATCH_SIZE - 1) // AUTHOR_BATCH_SIZE
|
||||
for i in range(0, len(author_ids), AUTHOR_BATCH_SIZE):
|
||||
batch = author_ids[i : i + AUTHOR_BATCH_SIZE]
|
||||
batch_no = i // AUTHOR_BATCH_SIZE + 1
|
||||
search_after = None
|
||||
while True:
|
||||
body: dict[str, Any] = {
|
||||
"size": WORK_PAGE_SIZE,
|
||||
"track_total_hits": True,
|
||||
"_source": WORK_SOURCE,
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"range": {"publication_year": {"gte": work_year_gte}}},
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"terms": {"authorships.author.id": batch}
|
||||
},
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
"sort": [{"id": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
result = es_search(client, NES_URL, NES_KEY, "openalex-works*", body)
|
||||
hits = result["hits"]["hits"]
|
||||
if not hits:
|
||||
break
|
||||
for hit in hits:
|
||||
src = hit["_source"]
|
||||
wid = src.get("id")
|
||||
if wid and wid not in works:
|
||||
works[wid] = src
|
||||
search_after = hits[-1]["sort"]
|
||||
print(f" work batch {batch_no}/{total_batches}: unique works {len(works)}")
|
||||
time.sleep(0.05)
|
||||
return works
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Cache IO
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def write_jsonl_gz(path: Path, records: Iterable[dict[str, Any]]) -> None:
|
||||
with gzip.open(path, "wt", encoding="utf-8", newline="\n") as f:
|
||||
for record in records:
|
||||
f.write(json.dumps(record, ensure_ascii=True) + "\n")
|
||||
|
||||
|
||||
def read_jsonl_gz(path: Path) -> Iterator[dict[str, Any]]:
|
||||
with gzip.open(path, "rt", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line:
|
||||
yield json.loads(line)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Top-level: extract to cache
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def extract_to_cache(
|
||||
institution_id: str,
|
||||
config: dict[str, Any],
|
||||
cache_dir: Path,
|
||||
force: bool = False,
|
||||
) -> tuple[Path, Path, list[dict[str, Any]]]:
|
||||
"""Extract authors + works for the cohort to jsonl.gz caches.
|
||||
|
||||
Returns (authors_path, works_path, resolved cohort institutions). Reuses an
|
||||
existing cache unless force=True.
|
||||
"""
|
||||
if not NES_URL or not NES_KEY:
|
||||
raise SystemExit(f"Missing NES credentials. Checked {ENV_PATH}")
|
||||
|
||||
short = institution_id.strip().rsplit("/", 1)[-1]
|
||||
cache_dir.mkdir(parents=True, exist_ok=True)
|
||||
authors_path = cache_dir / f"authors_{short}.jsonl.gz"
|
||||
works_path = cache_dir / f"works_{short}.jsonl.gz"
|
||||
|
||||
extraction_cfg = config.get("extraction") or {}
|
||||
affiliation_year_gte = int(extraction_cfg.get("affiliation_years_gte", 2023))
|
||||
work_year_gte = int(extraction_cfg.get("work_year_gte", 1950))
|
||||
|
||||
with httpx.Client() as client:
|
||||
insts = [
|
||||
resolve_institution(client, i) for i in cohort_ids_for(config, short)
|
||||
]
|
||||
print(f"Cohort ({len(insts)} institutions, affiliation years >= {affiliation_year_gte}):")
|
||||
for inst in insts:
|
||||
print(f" {inst['short_id']:<14} {inst['display_name']}")
|
||||
|
||||
if not force and authors_path.exists() and works_path.exists():
|
||||
print("Reusing cached extract (use --force-extract to refresh).")
|
||||
return authors_path, works_path, insts
|
||||
|
||||
print("\nExtracting authors...")
|
||||
authors = collect_authors(client, insts, affiliation_year_gte)
|
||||
write_jsonl_gz(authors_path, authors.values())
|
||||
print(f"Authors: {len(authors)} -> {authors_path}")
|
||||
|
||||
print("\nExtracting works (full authorships)...")
|
||||
works_map = collect_works(client, sorted(authors.keys()), work_year_gte)
|
||||
write_jsonl_gz(works_path, works_map.values())
|
||||
print(f"Works: {len(works_map)} -> {works_path}")
|
||||
|
||||
return authors_path, works_path, insts
|
||||
@@ -1,259 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
graph.py — co-author graph construction for multiplicator detection (M1, Stage C).
|
||||
|
||||
Input: the cached work extract (see spike_audit.py) as plain dicts.
|
||||
Output: plain-Python structures the metrics module consumes:
|
||||
|
||||
- edges: dict[(src, dst)] -> EdgeStats (undirected, src < dst, SHORT author ids)
|
||||
- nodes: dict[author_id] -> NodeStats (per-author aggregates over their works)
|
||||
|
||||
Design constraints (from the M0 spike):
|
||||
- Works with more than `max_authors_per_work` authors (default 50, chosen from the
|
||||
measured p90=17 / p99=144 distribution) are excluded from GRAPH construction only —
|
||||
a 4,839-author consortium paper is not a collaboration signal, but it still counts
|
||||
toward publication years, which are aggregated here in NodeStats for ALL works.
|
||||
- Edge weights follow the plan: sum of decay^(ref_year - year) / (n_authors - 1)
|
||||
per shared work, so recent, small-team collaborations weigh most.
|
||||
- All author/institution ids are shortened ("https://openalex.org/A5..." -> "A5...")
|
||||
to keep the adjacency structures small.
|
||||
|
||||
Everything here is pure computation over plain data — no I/O, no ES — so it is unit
|
||||
testable with hand-built fixtures.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Iterable
|
||||
|
||||
import polars as pl
|
||||
|
||||
OPENALEX_PREFIX = "https://openalex.org/"
|
||||
|
||||
|
||||
def short_id(raw: str | None) -> str | None:
|
||||
if not raw:
|
||||
return None
|
||||
return raw.rsplit("/", 1)[-1] if "/" in raw else raw
|
||||
|
||||
|
||||
@dataclass
|
||||
class EdgeStats:
|
||||
weight: float = 0.0 # decay- and team-size-weighted collaboration strength
|
||||
n_works: int = 0 # raw shared-work count
|
||||
cross_inst_weight: float = 0.0 # weight portion where the pair shared NO institution
|
||||
first_joint_year: int | None = None
|
||||
last_joint_year: int | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class NodeStats:
|
||||
display_name: str | None = None
|
||||
is_focal: bool = False # member of the institution author set
|
||||
publication_years: set[int] = field(default_factory=set) # ALL works (uncapped)
|
||||
n_works: int = 0 # ALL works (uncapped)
|
||||
field_counts: dict[str, int] = field(default_factory=dict) # primary_topic.field
|
||||
n_company_works: int = 0 # works with >=1 co-author institution type=company
|
||||
n_typed_works: int = 0 # works where >=1 institution has a non-null type
|
||||
# supervision signature inputs (per work, position-aware; capped works only)
|
||||
n_last_author_works: int = 0
|
||||
last_author_junior_first: list[tuple[str, int]] = field(default_factory=list)
|
||||
# ^ (first_author_id, year) for works where THIS node was last author
|
||||
|
||||
|
||||
@dataclass
|
||||
class Graph:
|
||||
edges: dict[tuple[str, str], EdgeStats]
|
||||
nodes: dict[str, NodeStats]
|
||||
n_works_used: int # works that entered pair generation
|
||||
n_works_capped: int # works excluded by max_authors_per_work
|
||||
ref_year: int # decay reference year
|
||||
|
||||
|
||||
def _work_author_rows(
|
||||
works: Iterable[dict[str, Any]],
|
||||
) -> tuple[list[dict[str, Any]], dict[str, dict[str, Any]]]:
|
||||
"""Flatten works into one row per (work, author) plus per-work metadata."""
|
||||
rows: list[dict[str, Any]] = []
|
||||
work_meta: dict[str, dict[str, Any]] = {}
|
||||
for w in works:
|
||||
wid = short_id(w.get("id"))
|
||||
year = w.get("publication_year")
|
||||
if not wid or not isinstance(year, int):
|
||||
continue
|
||||
authorships = w.get("authorships") or []
|
||||
seen: set[str] = set()
|
||||
work_rows = []
|
||||
has_company = False
|
||||
has_typed = False
|
||||
first_author: str | None = None
|
||||
last_author: str | None = None
|
||||
for a in authorships:
|
||||
aid = short_id((a.get("author") or {}).get("id"))
|
||||
if not aid or aid in seen:
|
||||
continue
|
||||
seen.add(aid)
|
||||
insts = a.get("institutions") or []
|
||||
inst_ids = frozenset(
|
||||
short_id(i.get("id")) for i in insts if i.get("id")
|
||||
)
|
||||
for i in insts:
|
||||
itype = i.get("type")
|
||||
if itype:
|
||||
has_typed = True
|
||||
if itype == "company":
|
||||
has_company = True
|
||||
position = a.get("author_position")
|
||||
if position == "first" and first_author is None:
|
||||
first_author = aid
|
||||
if position == "last":
|
||||
last_author = aid
|
||||
work_rows.append(
|
||||
{
|
||||
"work_id": wid,
|
||||
"year": year,
|
||||
"author_id": aid,
|
||||
"display_name": (a.get("author") or {}).get("display_name"),
|
||||
"inst_ids": inst_ids,
|
||||
}
|
||||
)
|
||||
n_authors = len(seen)
|
||||
field_id = short_id(((w.get("primary_topic") or {}).get("field") or {}).get("id"))
|
||||
work_meta[wid] = {
|
||||
"year": year,
|
||||
"n_authors": n_authors,
|
||||
"field_id": field_id,
|
||||
"has_company": has_company,
|
||||
"has_typed": has_typed,
|
||||
"first_author": first_author,
|
||||
"last_author": last_author,
|
||||
}
|
||||
rows.extend(work_rows)
|
||||
return rows, work_meta
|
||||
|
||||
|
||||
def build_graph(
|
||||
works: Iterable[dict[str, Any]],
|
||||
focal_author_ids: set[str],
|
||||
max_authors_per_work: int = 50,
|
||||
decay: float = 0.8,
|
||||
ref_year: int | None = None,
|
||||
) -> Graph:
|
||||
"""Build the weighted co-author graph and per-author aggregates.
|
||||
|
||||
`focal_author_ids` may contain full URLs or short ids; both are normalized.
|
||||
`ref_year` defaults to the max publication year in the corpus so results are
|
||||
deterministic for a given extract (never wall-clock dependent).
|
||||
"""
|
||||
focal = {short_id(a) for a in focal_author_ids}
|
||||
rows, work_meta = _work_author_rows(works)
|
||||
|
||||
if ref_year is None:
|
||||
ref_year = max((m["year"] for m in work_meta.values()), default=0)
|
||||
|
||||
# ---- node aggregates over ALL works (uncapped) ----
|
||||
nodes: dict[str, NodeStats] = {}
|
||||
for row in rows:
|
||||
aid = row["author_id"]
|
||||
node = nodes.get(aid)
|
||||
if node is None:
|
||||
node = nodes[aid] = NodeStats(
|
||||
display_name=row["display_name"], is_focal=aid in focal
|
||||
)
|
||||
meta = work_meta[row["work_id"]]
|
||||
node.publication_years.add(row["year"])
|
||||
node.n_works += 1
|
||||
if meta["field_id"]:
|
||||
node.field_counts[meta["field_id"]] = (
|
||||
node.field_counts.get(meta["field_id"], 0) + 1
|
||||
)
|
||||
if meta["has_typed"]:
|
||||
node.n_typed_works += 1
|
||||
if meta["has_company"]:
|
||||
node.n_company_works += 1
|
||||
|
||||
# supervision signature (uses author_position; only meaningful on capped works —
|
||||
# "last author" on a 500-author consortium paper is not a supervision signal)
|
||||
for wid, meta in work_meta.items():
|
||||
if not (2 <= meta["n_authors"] <= max_authors_per_work):
|
||||
continue
|
||||
la, fa = meta["last_author"], meta["first_author"]
|
||||
if la and la in nodes:
|
||||
nodes[la].n_last_author_works += 1
|
||||
if fa and fa != la:
|
||||
nodes[la].last_author_junior_first.append((fa, meta["year"]))
|
||||
|
||||
# ---- pair generation via polars self-join (capped works only) ----
|
||||
usable_work_ids = {
|
||||
wid
|
||||
for wid, meta in work_meta.items()
|
||||
if 2 <= meta["n_authors"] <= max_authors_per_work
|
||||
}
|
||||
n_capped = sum(
|
||||
1 for meta in work_meta.values() if meta["n_authors"] > max_authors_per_work
|
||||
)
|
||||
|
||||
pair_rows = [r for r in rows if r["work_id"] in usable_work_ids]
|
||||
edges: dict[tuple[str, str], EdgeStats] = {}
|
||||
if pair_rows:
|
||||
df = pl.DataFrame(
|
||||
{
|
||||
"work_id": [r["work_id"] for r in pair_rows],
|
||||
"author_id": [r["author_id"] for r in pair_rows],
|
||||
}
|
||||
)
|
||||
pairs = (
|
||||
df.join(df, on="work_id", suffix="_b")
|
||||
.filter(pl.col("author_id") < pl.col("author_id_b"))
|
||||
.select("work_id", "author_id", "author_id_b")
|
||||
)
|
||||
# institution sets are tiny per row; resolve shared-institution in Python
|
||||
inst_by_work_author: dict[tuple[str, str], frozenset] = {
|
||||
(r["work_id"], r["author_id"]): r["inst_ids"] for r in pair_rows
|
||||
}
|
||||
for wid, a, b in pairs.iter_rows():
|
||||
meta = work_meta[wid]
|
||||
year = meta["year"]
|
||||
w = (decay ** (ref_year - year)) / (meta["n_authors"] - 1)
|
||||
key = (a, b)
|
||||
e = edges.get(key)
|
||||
if e is None:
|
||||
e = edges[key] = EdgeStats()
|
||||
e.weight += w
|
||||
e.n_works += 1
|
||||
insts_a = inst_by_work_author[(wid, a)]
|
||||
insts_b = inst_by_work_author[(wid, b)]
|
||||
if not (insts_a & insts_b):
|
||||
e.cross_inst_weight += w
|
||||
if e.first_joint_year is None or year < e.first_joint_year:
|
||||
e.first_joint_year = year
|
||||
if e.last_joint_year is None or year > e.last_joint_year:
|
||||
e.last_joint_year = year
|
||||
|
||||
return Graph(
|
||||
edges=edges,
|
||||
nodes=nodes,
|
||||
n_works_used=len(usable_work_ids),
|
||||
n_works_capped=n_capped,
|
||||
ref_year=ref_year,
|
||||
)
|
||||
|
||||
|
||||
def adjacency(graph: Graph) -> dict[str, dict[str, float]]:
|
||||
"""Symmetric weighted adjacency over ALL nodes (focal + external)."""
|
||||
adj: dict[str, dict[str, float]] = {}
|
||||
for (a, b), e in graph.edges.items():
|
||||
adj.setdefault(a, {})[b] = e.weight
|
||||
adj.setdefault(b, {})[a] = e.weight
|
||||
return adj
|
||||
|
||||
|
||||
def focal_subgraph(graph: Graph) -> dict[str, dict[str, float]]:
|
||||
"""Adjacency restricted to focal (institution-internal) nodes only."""
|
||||
adj: dict[str, dict[str, float]] = {}
|
||||
for (a, b), e in graph.edges.items():
|
||||
na, nb = graph.nodes.get(a), graph.nodes.get(b)
|
||||
if na and nb and na.is_focal and nb.is_focal:
|
||||
adj.setdefault(a, {})[b] = e.weight
|
||||
adj.setdefault(b, {})[a] = e.weight
|
||||
return adj
|
||||
@@ -1,272 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
index.py — idempotent indexing of scored multiplicator rows into Elasticsearch.
|
||||
|
||||
Target: the `multiplicators_v1` index on the INSE cluster. The index was created by
|
||||
the cluster admin — the standard API key can read/write/update-mapping but NOT
|
||||
create or delete indices, so this module must never attempt index creation.
|
||||
|
||||
Idempotency: doc _id = "<institution_short>_<author_short>", and every run first
|
||||
deletes the institution's existing docs via a search + bulk-delete-by-id loop.
|
||||
That loop (not _delete_by_query) is deliberate: the same cluster rejects
|
||||
_delete_by_query with 403 for the org_patents key — see
|
||||
inse/patents/org/elastic_search_client.py for the precedent.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
|
||||
from extract import INSE_KEY, INSE_URL, _headers
|
||||
|
||||
MULTIPLICATORS_INDEX = "multiplicators_v1"
|
||||
NETWORKS_INDEX = "multiplicator_networks_v1"
|
||||
REQUEST_TIMEOUT = 120.0
|
||||
BULK_CHUNK = 500
|
||||
|
||||
MAPPING = {
|
||||
"properties": {
|
||||
"institution_id": {"type": "keyword"},
|
||||
"cohort_institution_ids": {"type": "keyword"},
|
||||
"author_id": {"type": "keyword"},
|
||||
"display_name": {
|
||||
"type": "text",
|
||||
"fields": {"keyword": {"type": "keyword", "ignore_above": 256}},
|
||||
},
|
||||
"career_bucket": {"type": "keyword"},
|
||||
"active_years": {"type": "integer"},
|
||||
"n_works": {"type": "integer"},
|
||||
"suspicious_profile": {"type": "boolean"},
|
||||
"tags": {"type": "keyword"},
|
||||
"max_sub_score": {"type": "float"},
|
||||
"sub_scores": {
|
||||
"properties": {
|
||||
"bridger": {"type": "float"},
|
||||
"mentor": {"type": "float"},
|
||||
"amplifier": {"type": "float"},
|
||||
}
|
||||
},
|
||||
# M3 signal counts
|
||||
"patent_count": {"type": "integer"},
|
||||
"patent_count_name_only": {"type": "integer"}, # evidence only, never scored
|
||||
"news_mentions": {"type": "integer"},
|
||||
"cordis_eu_projects": {"type": "integer"},
|
||||
"industry_coauthor_share_shrunk": {"type": "float"},
|
||||
# raw metrics + percentiles kept as dynamic float objects (calibration needs them)
|
||||
"percentiles": {"type": "object", "dynamic": True},
|
||||
"evidence": {
|
||||
"properties": {"junior_ids": {"type": "keyword"}},
|
||||
},
|
||||
"config_hash": {"type": "keyword"},
|
||||
"computed_at": {"type": "date"},
|
||||
}
|
||||
}
|
||||
|
||||
# Visualization docs: nodes/edges live in _source only ("enabled": false — never
|
||||
# indexed/queried per-field, the frontend GETs whole docs by _id or author filter),
|
||||
# which keeps the index small despite ~900 edge objects per doc.
|
||||
NETWORK_MAPPING = {
|
||||
"properties": {
|
||||
"institution_id": {"type": "keyword"},
|
||||
"cohort_institution_ids": {"type": "keyword"},
|
||||
"author_id": {"type": "keyword"},
|
||||
"display_name": {
|
||||
"type": "text",
|
||||
"fields": {"keyword": {"type": "keyword", "ignore_above": 256}},
|
||||
},
|
||||
"ego": {
|
||||
"properties": {
|
||||
"career_bucket": {"type": "keyword"},
|
||||
"active_years": {"type": "integer"},
|
||||
"n_works": {"type": "integer"},
|
||||
"suspicious_profile": {"type": "boolean"},
|
||||
"tags": {"type": "keyword"},
|
||||
"max_sub_score": {"type": "float"},
|
||||
"sub_scores": {
|
||||
"properties": {
|
||||
"bridger": {"type": "float"},
|
||||
"mentor": {"type": "float"},
|
||||
"amplifier": {"type": "float"},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
"total_coauthors": {"type": "integer"},
|
||||
"cohort_coauthors": {"type": "integer"},
|
||||
"mentee_count": {"type": "integer"},
|
||||
"shown": {"type": "integer"},
|
||||
"shown_mentees": {"type": "integer"},
|
||||
"nodes": {"type": "object", "enabled": False},
|
||||
"edges": {"type": "object", "enabled": False},
|
||||
"config_hash": {"type": "keyword"},
|
||||
"computed_at": {"type": "date"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MultiplicatorsIndexClient:
|
||||
def __init__(
|
||||
self,
|
||||
base_url: str | None = None,
|
||||
api_key: str | None = None,
|
||||
index: str = MULTIPLICATORS_INDEX,
|
||||
transport: httpx.BaseTransport | None = None,
|
||||
):
|
||||
self.base_url = (base_url or INSE_URL).rstrip("/")
|
||||
self.api_key = api_key if api_key is not None else INSE_KEY
|
||||
self.index = index
|
||||
self.client = httpx.Client(transport=transport, timeout=REQUEST_TIMEOUT)
|
||||
if not self.base_url or not self.api_key:
|
||||
raise SystemExit("Missing INSE cluster credentials (ELASTICSEARCH_INSE_*).")
|
||||
|
||||
def _request(self, method: str, path: str, **kwargs: Any) -> httpx.Response:
|
||||
return self.client.request(
|
||||
method,
|
||||
f"{self.base_url}/{path.lstrip('/')}",
|
||||
headers=_headers(self.api_key),
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def ensure_mapping(self, mapping: dict[str, Any] | None = None) -> None:
|
||||
"""PUT the explicit mapping (additive; safe on every run). Never creates the index."""
|
||||
response = self._request(
|
||||
"PUT", f"{self.index}/_mapping", json=mapping or MAPPING
|
||||
)
|
||||
if not response.is_success:
|
||||
raise RuntimeError(
|
||||
f"Mapping update failed ({response.status_code}): {response.text[:500]}"
|
||||
)
|
||||
|
||||
def count_for_institution(self, institution_short_id: str) -> int:
|
||||
response = self._request(
|
||||
"POST",
|
||||
f"{self.index}/_count",
|
||||
json={"query": {"term": {"institution_id": institution_short_id}}},
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()["count"]
|
||||
|
||||
def _wait_for_count(self, institution_short_id: str, expected: int,
|
||||
timeout_s: float = 30.0) -> int:
|
||||
"""Poll _count until it reaches `expected` or timeout.
|
||||
|
||||
The API key is NOT allowed to call _refresh (indices:admin/refresh -> 403),
|
||||
so visibility of deletes/writes depends on the index's auto-refresh
|
||||
(default 1s). Polling is the only verification available to this key."""
|
||||
deadline = time.time() + timeout_s
|
||||
count = -1
|
||||
while time.time() < deadline:
|
||||
count = self.count_for_institution(institution_short_id)
|
||||
if count == expected:
|
||||
return count
|
||||
time.sleep(1.0)
|
||||
return count
|
||||
|
||||
def _collect_ids_for_institution(self, institution_short_id: str) -> list[str]:
|
||||
"""All doc _ids for the institution, paginated with search_after (collected
|
||||
BEFORE any deletes, so stale-visibility cannot inflate or loop the delete)."""
|
||||
ids: list[str] = []
|
||||
search_after = None
|
||||
while True:
|
||||
body: dict[str, Any] = {
|
||||
"size": 1000,
|
||||
"_source": False,
|
||||
"query": {"term": {"institution_id": institution_short_id}},
|
||||
"sort": [{"author_id": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
response = self._request("POST", f"{self.index}/_search", json=body)
|
||||
response.raise_for_status()
|
||||
hits = response.json()["hits"]["hits"]
|
||||
if not hits:
|
||||
break
|
||||
ids.extend(h["_id"] for h in hits)
|
||||
search_after = hits[-1]["sort"]
|
||||
return ids
|
||||
|
||||
def delete_for_institution(self, institution_short_id: str) -> int:
|
||||
"""Collect ids, then bulk-delete-by-id (the key rejects _delete_by_query
|
||||
with 403). Returns the number of docs actually deleted."""
|
||||
ids = self._collect_ids_for_institution(institution_short_id)
|
||||
deleted = 0
|
||||
for start in range(0, len(ids), BULK_CHUNK):
|
||||
chunk = ids[start : start + BULK_CHUNK]
|
||||
lines = "".join(
|
||||
json.dumps({"delete": {"_index": self.index, "_id": doc_id}}) + "\n"
|
||||
for doc_id in chunk
|
||||
)
|
||||
bulk = self.client.post(
|
||||
f"{self.base_url}/_bulk",
|
||||
headers={**_headers(self.api_key), "Content-Type": "application/x-ndjson"},
|
||||
content=lines,
|
||||
)
|
||||
bulk.raise_for_status()
|
||||
for item in bulk.json()["items"]:
|
||||
result = item.get("delete", {})
|
||||
if result.get("result") == "deleted":
|
||||
deleted += 1
|
||||
elif result.get("error"):
|
||||
raise RuntimeError(f"Bulk delete error: {result['error']}")
|
||||
if ids:
|
||||
remaining = self._wait_for_count(institution_short_id, 0)
|
||||
if remaining != 0:
|
||||
raise RuntimeError(
|
||||
f"{remaining} docs for {institution_short_id} still visible "
|
||||
f"after delete (expected 0)"
|
||||
)
|
||||
return deleted
|
||||
|
||||
def index_rows(
|
||||
self,
|
||||
institution_short_id: str,
|
||||
cohort_short_ids: list[str],
|
||||
scored_rows: list[dict[str, Any]],
|
||||
) -> int:
|
||||
"""Delete-then-bulk-index all rows for the institution. Returns docs written."""
|
||||
computed_at = datetime.now(timezone.utc).isoformat()
|
||||
deleted = self.delete_for_institution(institution_short_id)
|
||||
print(f"Deleted {deleted} existing docs for {institution_short_id}")
|
||||
|
||||
written = 0
|
||||
for start in range(0, len(scored_rows), BULK_CHUNK):
|
||||
chunk = scored_rows[start : start + BULK_CHUNK]
|
||||
lines = []
|
||||
for row in chunk:
|
||||
doc = {
|
||||
**row,
|
||||
"institution_id": institution_short_id,
|
||||
"cohort_institution_ids": cohort_short_ids,
|
||||
"computed_at": computed_at,
|
||||
}
|
||||
doc_id = f"{institution_short_id}_{row['author_id']}"
|
||||
lines.append(
|
||||
json.dumps({"index": {"_index": self.index, "_id": doc_id}})
|
||||
)
|
||||
lines.append(json.dumps(doc, ensure_ascii=True))
|
||||
bulk = self.client.post(
|
||||
f"{self.base_url}/_bulk",
|
||||
headers={**_headers(self.api_key), "Content-Type": "application/x-ndjson"},
|
||||
content="\n".join(lines) + "\n",
|
||||
)
|
||||
bulk.raise_for_status()
|
||||
result = bulk.json()
|
||||
if result.get("errors"):
|
||||
first_error = next(
|
||||
(i["index"].get("error") for i in result["items"]
|
||||
if i.get("index", {}).get("error")),
|
||||
None,
|
||||
)
|
||||
raise RuntimeError(f"Bulk indexing reported errors, first: {first_error}")
|
||||
written += len(chunk)
|
||||
visible = self._wait_for_count(institution_short_id, written)
|
||||
if visible != written:
|
||||
raise RuntimeError(
|
||||
f"Post-index count mismatch for {institution_short_id}: "
|
||||
f"wrote {written}, index shows {visible} after 30s"
|
||||
)
|
||||
return written
|
||||
@@ -1,264 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
make_report.py — render the ego-network HTML report from the LIVE ES indices.
|
||||
|
||||
Reads `multiplicators_v1` (scores) + `multiplicator_networks_v1` (nodes/edges) —
|
||||
the same two documents a frontend service would fetch — and writes a single
|
||||
self-contained HTML file to reports/. No local cache needed: the report can be
|
||||
regenerated any time after a build, on any machine with cluster access.
|
||||
|
||||
python make_report.py --institution-id I62318514
|
||||
python make_report.py --institution-id I62318514 \
|
||||
--author-ids A5113304257,A5043495754 # explicit cast instead of auto-pick
|
||||
|
||||
By default it picks one showcase per tag (highest bridger / mentor / amplifier)
|
||||
plus the highest-scoring person who just misses the tag threshold — the four
|
||||
contrasting cases that make the metrics legible.
|
||||
|
||||
The force-directed layout is computed here and baked into the file so the report
|
||||
stays dependency-free; a real frontend should instead let echarts' `graph` series
|
||||
lay out the same nodes/edges live.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
import yaml
|
||||
from dotenv import load_dotenv
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
ENV_PATH = SCRIPT_DIR.parent.parent / "src" / "main" / "inse" / ".env"
|
||||
load_dotenv(dotenv_path=ENV_PATH)
|
||||
|
||||
INSE_URL = (os.environ.get("ELASTICSEARCH_INSE_URL") or "").rstrip("/")
|
||||
INSE_KEY = os.environ.get("ELASTICSEARCH_INSE_API_KEY") or ""
|
||||
SCORES_INDEX = "multiplicators_v1"
|
||||
NETWORKS_INDEX = "multiplicator_networks_v1"
|
||||
|
||||
SCORE_FIELDS = (
|
||||
"author_id", "display_name", "career_bucket", "active_years", "n_works",
|
||||
"suspicious_profile", "tags", "sub_scores", "percentiles", "betweenness",
|
||||
"brokerage", "constraint", "field_entropy", "cross_institution_share",
|
||||
"strength", "n_coauthors", "industry_coauthor_share",
|
||||
"industry_coauthor_share_shrunk", "juniors_mentored",
|
||||
"junior_progression_rate", "mentoring_rate", "last_author_with_junior_first",
|
||||
"patent_count", "news_mentions", "cordis_eu_projects",
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# ES access
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def _headers() -> dict[str, str]:
|
||||
return {"Authorization": f"ApiKey {INSE_KEY}", "Content-Type": "application/json"}
|
||||
|
||||
|
||||
def es_get(client: httpx.Client, index: str, doc_id: str) -> dict | None:
|
||||
r = client.get(f"{INSE_URL}/{index}/_doc/{doc_id}", headers=_headers(), timeout=30)
|
||||
if r.status_code == 404:
|
||||
return None
|
||||
r.raise_for_status()
|
||||
return r.json()["_source"]
|
||||
|
||||
|
||||
def es_search(client: httpx.Client, index: str, body: dict) -> dict:
|
||||
r = client.post(f"{INSE_URL}/{index}/_search", headers=_headers(), json=body, timeout=60)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
|
||||
def pick_showcase(client: httpx.Client, institution: str) -> list[tuple[str, str]]:
|
||||
"""(author_id, kind) for the top bridger / mentor / amplifier + top near-miss."""
|
||||
picks: list[tuple[str, str]] = []
|
||||
seen: set[str] = set()
|
||||
for tag in ("bridger", "mentor", "amplifier"):
|
||||
res = es_search(client, SCORES_INDEX, {
|
||||
"size": 5,
|
||||
"_source": ["author_id"],
|
||||
"query": {"bool": {"filter": [
|
||||
{"term": {"institution_id": institution}},
|
||||
{"term": {"tags": tag}},
|
||||
]}},
|
||||
"sort": [{f"sub_scores.{tag}": {"order": "desc"}}],
|
||||
})
|
||||
for hit in res["hits"]["hits"]:
|
||||
aid = hit["_source"]["author_id"]
|
||||
if aid not in seen:
|
||||
picks.append((aid, tag))
|
||||
seen.add(aid)
|
||||
break
|
||||
# highest scorer that carries no tag — shows where the threshold bites
|
||||
res = es_search(client, SCORES_INDEX, {
|
||||
"size": 5,
|
||||
"_source": ["author_id"],
|
||||
"query": {"bool": {
|
||||
"filter": [{"term": {"institution_id": institution}}],
|
||||
"must_not": [{"exists": {"field": "tags"}}],
|
||||
}},
|
||||
"sort": [{"max_sub_score": {"order": "desc"}}],
|
||||
})
|
||||
for hit in res["hits"]["hits"]:
|
||||
aid = hit["_source"]["author_id"]
|
||||
if aid not in seen:
|
||||
picks.append((aid, "example"))
|
||||
seen.add(aid)
|
||||
break
|
||||
return picks
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Layout
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def fr_layout(node_ids, edge_list, w=760, h=560, iters=350, seed=7):
|
||||
"""Fruchterman-Reingold with the ego pinned to the centre (deterministic seed)."""
|
||||
rng = random.Random(seed)
|
||||
pos = {n: [rng.uniform(0, w), rng.uniform(0, h)] for n in node_ids}
|
||||
ego = node_ids[0]
|
||||
pos[ego] = [w / 2, h / 2]
|
||||
k = math.sqrt(w * h / max(len(node_ids), 1)) * 0.9
|
||||
t = w / 8
|
||||
wmax = max((e[2] for e in edge_list), default=1.0)
|
||||
for _ in range(iters):
|
||||
disp = {n: [0.0, 0.0] for n in node_ids}
|
||||
for i, a in enumerate(node_ids):
|
||||
for b in node_ids[i + 1:]:
|
||||
dx = pos[a][0] - pos[b][0]
|
||||
dy = pos[a][1] - pos[b][1]
|
||||
d = max(math.hypot(dx, dy), 0.01)
|
||||
f = k * k / d
|
||||
disp[a][0] += dx / d * f; disp[a][1] += dy / d * f
|
||||
disp[b][0] -= dx / d * f; disp[b][1] -= dy / d * f
|
||||
for a, b, wt in edge_list:
|
||||
dx = pos[a][0] - pos[b][0]
|
||||
dy = pos[a][1] - pos[b][1]
|
||||
d = max(math.hypot(dx, dy), 0.01)
|
||||
f = d * d / k * (0.3 + 0.7 * wt / wmax)
|
||||
disp[a][0] -= dx / d * f; disp[a][1] -= dy / d * f
|
||||
disp[b][0] += dx / d * f; disp[b][1] += dy / d * f
|
||||
for n in node_ids:
|
||||
if n == ego:
|
||||
continue
|
||||
dx, dy = disp[n]
|
||||
d = max(math.hypot(dx, dy), 0.01)
|
||||
pos[n][0] = min(w - 20, max(20, pos[n][0] + dx / d * min(d, t)))
|
||||
pos[n][1] = min(h - 20, max(20, pos[n][1] + dy / d * min(d, t)))
|
||||
t *= 0.97
|
||||
return pos
|
||||
|
||||
|
||||
def compose(client: httpx.Client, institution: str, picks: list[tuple[str, str]]) -> dict:
|
||||
out: dict[str, dict] = {}
|
||||
for author_id, kind in picks:
|
||||
doc_id = f"{institution}_{author_id}"
|
||||
net = es_get(client, NETWORKS_INDEX, doc_id)
|
||||
score = es_get(client, SCORES_INDEX, doc_id)
|
||||
if not net or not score:
|
||||
print(f" skip {author_id}: missing doc", file=sys.stderr)
|
||||
continue
|
||||
node_ids = [n["id"] for n in net["nodes"]]
|
||||
pos = fr_layout(node_ids, [(e["a"], e["b"], e["w"]) for e in net["edges"]])
|
||||
nodes = []
|
||||
for n in net["nodes"]:
|
||||
entry = {
|
||||
"id": n["id"], "name": n["name"], "role": n["role"],
|
||||
"inst": n.get("inst", ""), "active_years": n["active_years"],
|
||||
"x": round(pos[n["id"]][0], 1), "y": round(pos[n["id"]][1], 1),
|
||||
}
|
||||
if n.get("company_insts"):
|
||||
entry["company_insts"] = n["company_insts"]
|
||||
nodes.append(entry)
|
||||
out[author_id] = {
|
||||
"kind": kind,
|
||||
"score_row": {k: score[k] for k in SCORE_FIELDS if k in score},
|
||||
"total_coauthors": net["total_coauthors"],
|
||||
"shown": net["shown"],
|
||||
"nodes": nodes,
|
||||
"edges": [
|
||||
{"a": e["a"], "b": e["b"], "w": e["w"], "n": e["n_works"],
|
||||
"cross": e["cross"], "y0": e["first_year"]}
|
||||
for e in net["edges"]
|
||||
],
|
||||
"config_hash": score.get("config_hash", ""),
|
||||
"computed_at": (score.get("computed_at") or "")[:10],
|
||||
}
|
||||
roles: dict[str, int] = {}
|
||||
for n in nodes:
|
||||
roles[n["role"]] = roles.get(n["role"], 0) + 1
|
||||
print(f" {kind:<10} {score.get('display_name')}: {roles}", file=sys.stderr)
|
||||
return out
|
||||
|
||||
|
||||
TEMPLATE_PATH = SCRIPT_DIR / "report_template.html"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--institution-id", required=True)
|
||||
parser.add_argument(
|
||||
"--author-ids", default="",
|
||||
help="Comma-separated author IDs to feature. Overrides report.featured_author_ids "
|
||||
"in the config; pass --auto to force automatic selection instead.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--auto", action="store_true",
|
||||
help="Ignore the pinned cast and auto-select the current top scorer per tag.",
|
||||
)
|
||||
parser.add_argument("--config", default=str(SCRIPT_DIR / "multipliers.yaml"))
|
||||
parser.add_argument("--out", default=str(SCRIPT_DIR / "reports" / "multiplier_networks.html"))
|
||||
args = parser.parse_args()
|
||||
|
||||
if not INSE_URL or not INSE_KEY:
|
||||
raise SystemExit(f"Missing INSE credentials. Checked {ENV_PATH}")
|
||||
|
||||
institution = args.institution_id.strip().rsplit("/", 1)[-1]
|
||||
|
||||
# cast precedence: --author-ids > --auto > config pin > automatic
|
||||
pinned: list[str] = []
|
||||
if not args.auto and not args.author_ids:
|
||||
config_path = Path(args.config)
|
||||
if config_path.exists():
|
||||
config = yaml.safe_load(config_path.read_text(encoding="utf-8")) or {}
|
||||
pinned = [
|
||||
str(a) for a in ((config.get("report") or {}).get("featured_author_ids") or [])
|
||||
]
|
||||
|
||||
with httpx.Client() as client:
|
||||
ids = [a.strip() for a in args.author_ids.split(",") if a.strip()] or pinned
|
||||
if ids:
|
||||
kinds = ["bridger", "mentor", "amplifier", "example"]
|
||||
picks = [(a, kinds[i] if i < len(kinds) else "example")
|
||||
for i, a in enumerate(ids)]
|
||||
source = "config-pinned" if pinned and not args.author_ids else "explicit"
|
||||
print(f"Cast ({source}): {[p[0] for p in picks]}", file=sys.stderr)
|
||||
else:
|
||||
picks = pick_showcase(client, institution)
|
||||
print(f"Auto-selected showcase: {[p[0] for p in picks]}", file=sys.stderr)
|
||||
data = compose(client, institution, picks)
|
||||
|
||||
if not data:
|
||||
raise SystemExit("No documents found — has build.py run for this institution?")
|
||||
|
||||
template = TEMPLATE_PATH.read_text(encoding="utf-8")
|
||||
payload = json.dumps(data, ensure_ascii=True)
|
||||
assert "</script" not in payload, "data would break out of the script tag"
|
||||
html = template.replace("__DATA__", payload)
|
||||
|
||||
out_path = Path(args.out)
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
out_path.write_text(html, encoding="utf-8")
|
||||
print(f"Report -> {out_path} ({len(html):,} bytes, {len(data)} cases)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,341 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
metrics.py — bridger / mentor metrics for multiplicator detection (M1, Stage D).
|
||||
|
||||
All functions are pure computations over the structures produced by graph.py.
|
||||
|
||||
Career-age foundation (see analysis/career_stage/README.md): first_publication_year is
|
||||
UNRELIABLE at UDE (merged OpenAlex profiles -> debut years like 1893), so nothing here
|
||||
uses it. The robust primitive is the prefix-counted active-year count
|
||||
|
||||
active_years_at(A, Y) = |{ y in distinct_publication_years(A) : y <= Y }|
|
||||
|
||||
which a single misattributed old work moves by exactly 1. It inherits the empirically
|
||||
validated career-stage thresholds from inse/persons/logic.py unchanged.
|
||||
|
||||
Mentor metrics are computed over FOCAL (institution-internal) pairs only: the extract
|
||||
contains the complete global history of focal authors, so their year-sets are exact,
|
||||
while external co-authors' year-sets are truncated to shared works (an external senior
|
||||
would look junior). This scope restriction is a data-correctness requirement, not a
|
||||
modelling choice.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import heapq
|
||||
import math
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from graph import EdgeStats, Graph, adjacency, focal_subgraph
|
||||
|
||||
|
||||
def incident_edges(graph: Graph) -> dict[str, list[tuple[str, EdgeStats]]]:
|
||||
"""One pass over the edge dict -> per-author incident edge lists.
|
||||
|
||||
Every per-author metric must use this instead of scanning graph.edges —
|
||||
a full-edge scan per focal author is O(E * authors) and does not finish."""
|
||||
incident: dict[str, list[tuple[str, EdgeStats]]] = {}
|
||||
for (a, b), e in graph.edges.items():
|
||||
incident.setdefault(a, []).append((b, e))
|
||||
incident.setdefault(b, []).append((a, e))
|
||||
return incident
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Career primitives
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def active_years_at(publication_years: set[int], year: int) -> int:
|
||||
"""Distinct publication years up to and including `year` (robust seniority)."""
|
||||
return sum(1 for y in publication_years if y <= year)
|
||||
|
||||
|
||||
def is_suspicious_profile(publication_years: set[int]) -> bool:
|
||||
"""Merged-profile flag, same rule as inse/persons/logic.py."""
|
||||
if not publication_years:
|
||||
return False
|
||||
first = min(publication_years)
|
||||
span = max(publication_years) - first + 1
|
||||
return first < 1970 or span > 60
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Betweenness — Brandes (2001), weighted variant with Dijkstra.
|
||||
# Weights are collaboration STRENGTHS; shortest paths need DISTANCES, so we
|
||||
# pass 1/weight (strong ties = short distances). Pure stdlib.
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def betweenness_centrality(
|
||||
adj: dict[str, dict[str, float]], normalized: bool = True
|
||||
) -> dict[str, float]:
|
||||
nodes = list(adj.keys())
|
||||
bc = {v: 0.0 for v in nodes}
|
||||
|
||||
for s in nodes:
|
||||
# single-source shortest paths (Dijkstra on 1/weight distances).
|
||||
# All per-source state is lazy (touched nodes only) — a per-source init
|
||||
# over all V nodes would make the whole thing O(V^2) before any work.
|
||||
dist: dict[str, float] = {s: 0.0}
|
||||
sigma: dict[str, float] = {s: 1.0}
|
||||
preds: dict[str, list[str]] = {}
|
||||
done: set[str] = set()
|
||||
order: list[str] = []
|
||||
heap: list[tuple[float, str]] = [(0.0, s)]
|
||||
while heap:
|
||||
d, v = heapq.heappop(heap)
|
||||
if v in done:
|
||||
continue
|
||||
done.add(v)
|
||||
order.append(v)
|
||||
sigma_v = sigma[v]
|
||||
for u, w in adj[v].items():
|
||||
if w <= 0:
|
||||
continue
|
||||
nd = d + 1.0 / w
|
||||
old = dist.get(u)
|
||||
if old is None or nd < old - 1e-12:
|
||||
dist[u] = nd
|
||||
sigma[u] = sigma_v
|
||||
preds[u] = [v]
|
||||
heapq.heappush(heap, (nd, u))
|
||||
elif abs(nd - old) <= 1e-12 and u not in done:
|
||||
sigma[u] += sigma_v
|
||||
preds.setdefault(u, []).append(v)
|
||||
# accumulation, reverse order of discovery
|
||||
delta: dict[str, float] = {}
|
||||
for v in reversed(order):
|
||||
dv = delta.get(v, 0.0)
|
||||
coeff = (1.0 + dv) / sigma[v]
|
||||
for p in preds.get(v, ()):
|
||||
delta[p] = delta.get(p, 0.0) + sigma[p] * coeff
|
||||
if v != s:
|
||||
bc[v] += dv
|
||||
|
||||
# undirected: each pair counted twice
|
||||
for v in bc:
|
||||
bc[v] /= 2.0
|
||||
if normalized and len(nodes) > 2:
|
||||
scale = 1.0 / ((len(nodes) - 1) * (len(nodes) - 2) / 2.0)
|
||||
for v in bc:
|
||||
bc[v] *= scale
|
||||
return bc
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Burt's constraint — low constraint == structural-hole spanner (bridger).
|
||||
# Computed on the FULL graph (external co-authors included): someone whose
|
||||
# UDE-internal network is dense but who alone connects to industry/abroad
|
||||
# is a bridger that internal betweenness cannot see.
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def burt_constraint(
|
||||
adj: dict[str, dict[str, float]], nodes: list[str] | None = None
|
||||
) -> dict[str, float]:
|
||||
"""Constraint c_i = sum_j (p_ij + sum_q p_iq * p_qj)^2 over neighbours j of i.
|
||||
|
||||
p_ij = w_ij / sum_k w_ik. Isolates get constraint 1.0 (fully constrained).
|
||||
"""
|
||||
# strength totals once — recomputing sum(neigh.values()) inside the O(d^2)
|
||||
# inner loop makes this O(d^3) and unusable on hub nodes
|
||||
totals = {v: sum(neigh.values()) for v, neigh in adj.items()}
|
||||
|
||||
result: dict[str, float] = {}
|
||||
targets = nodes if nodes is not None else list(adj.keys())
|
||||
for i in targets:
|
||||
neigh = adj.get(i) or {}
|
||||
total = totals.get(i, 0.0)
|
||||
if total <= 0:
|
||||
result[i] = 1.0
|
||||
continue
|
||||
p_i = {j: w / total for j, w in neigh.items()}
|
||||
c = 0.0
|
||||
for j, p_ij in p_i.items():
|
||||
indirect = 0.0
|
||||
for q, p_iq in p_i.items():
|
||||
if q == j:
|
||||
continue
|
||||
q_neigh = adj.get(q)
|
||||
if not q_neigh:
|
||||
continue
|
||||
w_qj = q_neigh.get(j)
|
||||
if w_qj:
|
||||
indirect += p_iq * (w_qj / totals[q])
|
||||
c += (p_ij + indirect) ** 2
|
||||
result[i] = c
|
||||
return result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Simple per-node shares
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def field_entropy(field_counts: dict[str, int]) -> float:
|
||||
"""Shannon entropy (bits) over primary_topic.field of an author's works."""
|
||||
total = sum(field_counts.values())
|
||||
if total <= 0:
|
||||
return 0.0
|
||||
ent = 0.0
|
||||
for c in field_counts.values():
|
||||
if c > 0:
|
||||
p = c / total
|
||||
ent -= p * math.log2(p)
|
||||
return ent
|
||||
|
||||
|
||||
def cross_institution_share(
|
||||
graph: Graph,
|
||||
author_id: str,
|
||||
incident: dict[str, list[tuple[str, EdgeStats]]] | None = None,
|
||||
) -> float:
|
||||
"""Share of an author's edge weight where the pair shared no institution."""
|
||||
if incident is None:
|
||||
incident = incident_edges(graph)
|
||||
total = 0.0
|
||||
cross = 0.0
|
||||
for _, e in incident.get(author_id, ()):
|
||||
total += e.weight
|
||||
cross += e.cross_inst_weight
|
||||
return cross / total if total > 0 else 0.0
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Mentor metrics — debut-year-free (see module docstring)
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass
|
||||
class MentorMetrics:
|
||||
juniors_mentored: int = 0
|
||||
junior_progression_rate: float | None = None # None if no juniors
|
||||
last_author_with_junior_first: int = 0
|
||||
mentoring_rate: float = 0.0
|
||||
junior_ids: list[str] = field(default_factory=list) # evidence
|
||||
|
||||
|
||||
def mentor_metrics(
|
||||
graph: Graph,
|
||||
focal_author_id: str,
|
||||
junior_active_years_max: int = 4,
|
||||
senior_active_years_min: int = 10,
|
||||
progressed_active_years_min: int = 5,
|
||||
incident: dict[str, list[tuple[str, EdgeStats]]] | None = None,
|
||||
) -> MentorMetrics:
|
||||
"""Seniority-gap mentorship over focal-internal pairs.
|
||||
|
||||
A co-author J counts as "mentored" when, at the year Y of the FIRST joint work:
|
||||
active_years_at(J, Y) <= junior_active_years_max (J was Early-career)
|
||||
active_years_at(focal, Y) >= senior_active_years_min (focal was Established+)
|
||||
Progression: J later reached >= progressed_active_years_min total active years.
|
||||
"""
|
||||
focal_node = graph.nodes.get(focal_author_id)
|
||||
if focal_node is None:
|
||||
return MentorMetrics()
|
||||
if incident is None:
|
||||
incident = incident_edges(graph)
|
||||
|
||||
juniors: list[str] = []
|
||||
progressed = 0
|
||||
for other, e in incident.get(focal_author_id, ()):
|
||||
if e.first_joint_year is None:
|
||||
continue
|
||||
other_node = graph.nodes.get(other)
|
||||
if other_node is None or not other_node.is_focal or not focal_node.is_focal:
|
||||
continue # internal pairs only — external year-sets are truncated
|
||||
y = e.first_joint_year
|
||||
if (
|
||||
active_years_at(other_node.publication_years, y) <= junior_active_years_max
|
||||
and active_years_at(focal_node.publication_years, y) >= senior_active_years_min
|
||||
):
|
||||
juniors.append(other)
|
||||
if len(other_node.publication_years) >= progressed_active_years_min:
|
||||
progressed += 1
|
||||
|
||||
# supervision signature: focal last author, junior (at that work's year) first author
|
||||
last_author_junior_first = 0
|
||||
for first_author, year in focal_node.last_author_junior_first:
|
||||
fa_node = graph.nodes.get(first_author)
|
||||
if fa_node is None or not fa_node.is_focal:
|
||||
continue
|
||||
if active_years_at(fa_node.publication_years, year) <= junior_active_years_max:
|
||||
last_author_junior_first += 1
|
||||
|
||||
total_active = len(focal_node.publication_years)
|
||||
return MentorMetrics(
|
||||
juniors_mentored=len(juniors),
|
||||
junior_progression_rate=(progressed / len(juniors)) if juniors else None,
|
||||
last_author_with_junior_first=last_author_junior_first,
|
||||
mentoring_rate=(len(juniors) / total_active) if total_active else 0.0,
|
||||
junior_ids=juniors,
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Orchestration: all raw metrics for every focal author
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def compute_all_metrics(
|
||||
graph: Graph,
|
||||
junior_active_years_max: int = 4,
|
||||
senior_active_years_min: int = 10,
|
||||
progressed_active_years_min: int = 5,
|
||||
industry_share_shrinkage_k: int = 5,
|
||||
) -> dict[str, dict]:
|
||||
"""Raw (un-normalized) metric rows keyed by focal author id."""
|
||||
internal = focal_subgraph(graph)
|
||||
full_adj = adjacency(graph)
|
||||
incident = incident_edges(graph)
|
||||
focal_ids = [aid for aid, n in graph.nodes.items() if n.is_focal]
|
||||
|
||||
bc = betweenness_centrality(internal) if internal else {}
|
||||
constraint = burt_constraint(full_adj, nodes=[a for a in focal_ids if a in full_adj])
|
||||
|
||||
rows: dict[str, dict] = {}
|
||||
for aid in focal_ids:
|
||||
node = graph.nodes[aid]
|
||||
mm = mentor_metrics(
|
||||
graph,
|
||||
aid,
|
||||
junior_active_years_max=junior_active_years_max,
|
||||
senior_active_years_min=senior_active_years_min,
|
||||
progressed_active_years_min=progressed_active_years_min,
|
||||
incident=incident,
|
||||
)
|
||||
strength = sum(full_adj.get(aid, {}).values())
|
||||
rows[aid] = {
|
||||
"author_id": aid,
|
||||
"display_name": node.display_name,
|
||||
"active_years": len(node.publication_years),
|
||||
"n_works": node.n_works,
|
||||
"suspicious_profile": is_suspicious_profile(node.publication_years),
|
||||
# bridger
|
||||
"betweenness": bc.get(aid, 0.0),
|
||||
"constraint": constraint.get(aid, 1.0),
|
||||
"brokerage": 1.0 - constraint.get(aid, 1.0), # higher = more bridging
|
||||
"field_entropy": field_entropy(node.field_counts),
|
||||
"cross_institution_share": cross_institution_share(graph, aid, incident),
|
||||
"strength": strength,
|
||||
"n_coauthors": len(full_adj.get(aid, {})),
|
||||
# amplifier inputs available from OpenAlex alone
|
||||
"industry_coauthor_share": (
|
||||
node.n_company_works / node.n_typed_works if node.n_typed_works else 0.0
|
||||
),
|
||||
# shrunk variant for SCORING: n_company/(n_typed+k) damps the small-
|
||||
# denominator artifact where 2-of-2 company works outranks 40-of-80 —
|
||||
# the live index's top "amplifiers" were exactly such ratio artifacts
|
||||
"industry_coauthor_share_shrunk": (
|
||||
node.n_company_works / (node.n_typed_works + industry_share_shrinkage_k)
|
||||
if node.n_typed_works
|
||||
else 0.0
|
||||
),
|
||||
# mentor
|
||||
"juniors_mentored": mm.juniors_mentored,
|
||||
"junior_progression_rate": mm.junior_progression_rate,
|
||||
"last_author_with_junior_first": mm.last_author_with_junior_first,
|
||||
"mentoring_rate": mm.mentoring_rate,
|
||||
"junior_ids": mm.junior_ids,
|
||||
}
|
||||
return rows
|
||||
@@ -1,121 +0,0 @@
|
||||
# Multiplicator detection — all tunables live here.
|
||||
# Coaches will retune weights/thresholds; every output doc carries a config_hash
|
||||
# of this file so scores stay attributable to the weighting that produced them.
|
||||
|
||||
version: 2
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Cohorts — which OpenAlex institutions constitute "the university".
|
||||
#
|
||||
# Keyed by the primary institution ID passed as --institution-id. If a cohort
|
||||
# entry exists, the author set is extracted over ALL listed IDs; otherwise the
|
||||
# primary ID alone is used. Needed because OpenAlex does NOT model university
|
||||
# hospitals as lineage children: Essen University Hospital is only "related"
|
||||
# to UDE, which silently excluded ~2,437 active clinicians (incl. prominent
|
||||
# medicine professors) from the cohort — found via the M1 validation, where
|
||||
# 17/60 hand-labeled people were missing.
|
||||
#
|
||||
# Source of candidates: openalex-institutions `associated_institutions` of the
|
||||
# primary ID (children + related), one hop deep. Every inclusion/exclusion is
|
||||
# a human judgment call — document the reason next to each entry.
|
||||
# ---------------------------------------------------------------------------
|
||||
cohorts:
|
||||
I62318514:
|
||||
name: University of Duisburg-Essen
|
||||
institution_ids:
|
||||
- I62318514 # UDE itself (primary)
|
||||
- I4210119759 # Essen University Hospital — the university medical centre;
|
||||
# "related" in OpenAlex, NOT lineage, hence the coverage gap
|
||||
- I4210161917 # West German Heart and Vascular Center Essen — child of the hospital
|
||||
- I127668822 # Erwin L. Hahn Institute for MRI — joint UDE institute,
|
||||
# isolated in OpenAlex (no lineage/associated links at all)
|
||||
- I4210090139 # Rhein-Ruhr Institut für Sozialforschung (child of UDE)
|
||||
- I4210092428 # Deutsches Textilforschungszentrum Nord-West (child of UDE)
|
||||
- I4210110714 # Institute for Advanced Study in the Humanities Essen / KWI (child)
|
||||
- I4210146441 # The Hydrogen and Fuel Cell Center / ZBT (child of UDE)
|
||||
- I4210154243 # Institut für Energie- und Umwelttechnik / IUTA (child of UDE)
|
||||
# Deliberately EXCLUDED (decide with the coaches before enabling):
|
||||
# - I4210146447 Kliniken Essen-Mitte — independent hospital group, only
|
||||
# "related"; staff are not UDE researchers (~788 authors)
|
||||
# - I2799342142 Salomon Ludwig Steinheim-Institut — independent An-Institut
|
||||
# - I4210124583 IWW Water Centre — independent An-Institut
|
||||
|
||||
extraction:
|
||||
# "Recent affiliation" cutoff for the author set. 2023 (not the current year):
|
||||
# publication lag pushes current staff out of a 1-year window — the M1 validation
|
||||
# found 6 current-ish people (incl. an active professor) with newest affiliation
|
||||
# year 2021-2024. 2023 captures normal lag while still excluding long-departed.
|
||||
affiliation_years_gte: 2023
|
||||
work_year_gte: 1950
|
||||
# Chosen from the M0 spike (authors/work p50=5, p90=17, p99=144, max=4839):
|
||||
# cap 50 keeps >=99% of works and excludes only true hyperauthorship, which
|
||||
# carries no collaboration signal but would create giant artificial cliques.
|
||||
max_authors_per_work: 50
|
||||
|
||||
graph:
|
||||
decay: 0.8 # per-year edge weight decay (ref = newest corpus year)
|
||||
|
||||
career:
|
||||
# active_years bucket thresholds — mirror inse/persons/logic.py _classify_career_stage.
|
||||
# Buckets: Early <= 4, Emerging <= 9, Established <= 14, Senior > 14.
|
||||
buckets: [4, 9, 14]
|
||||
bucket_names: [Early, Emerging, Established, Senior]
|
||||
|
||||
mentor:
|
||||
junior_active_years_max: 4 # junior == Early-career at first joint work
|
||||
senior_active_years_min: 10 # focal must be Established+ at first joint work
|
||||
progressed_active_years_min: 5
|
||||
|
||||
signals:
|
||||
# org_patents match_types that count toward the score; "name"-only matches are
|
||||
# carried as evidence (patent_count_name_only) but never scored.
|
||||
patent_match_types: [institution, both]
|
||||
news_require_relevant: true # only aktuell_postproc docs the LLM marked relevant
|
||||
# Shrinkage constant for industry_coauthor_share_shrunk = company/(typed+k):
|
||||
# damps small denominators (2-of-2 works with a company co-author is not a
|
||||
# stronger industry signal than 40-of-80). Found via the live-index audit,
|
||||
# where all top-10 "amplifiers" were such ratio artifacts.
|
||||
industry_share_shrinkage_k: 5
|
||||
|
||||
network:
|
||||
# Per-author ego-network docs for the visualization frontend
|
||||
# (index multiplicator_networks_v1). Nodes shown = strongest co-authors by tie
|
||||
# weight, with mentees force-included first — their decayed, team-size-divided
|
||||
# ties otherwise never make the cut (a 100-mentee professor had ZERO mentees
|
||||
# in his unforced top 42).
|
||||
max_nodes: 42
|
||||
max_forced_mentees: 14
|
||||
|
||||
# Sub-score weights over WITHIN-BUCKET percentiles of the raw metrics.
|
||||
# Weights within each sub-score should sum to 1.
|
||||
weights:
|
||||
bridger:
|
||||
betweenness: 0.35
|
||||
brokerage: 0.25 # 1 - Burt constraint, full graph incl. externals
|
||||
field_entropy: 0.20
|
||||
cross_institution_share: 0.20
|
||||
mentor:
|
||||
juniors_mentored: 0.35
|
||||
mentoring_rate: 0.25
|
||||
last_author_with_junior_first: 0.25
|
||||
junior_progression_rate: 0.15
|
||||
amplifier:
|
||||
industry_coauthor_share_shrunk: 0.50 # primary: ID-linked company co-authorship, shrunk
|
||||
patent_count: 0.25 # high-confidence org_patents (institution/both)
|
||||
cordis_eu_projects: 0.15 # DOI-join, no name matching
|
||||
news_mentions: 0.10 # normalized-exact name match — lossy; keep low
|
||||
|
||||
tags:
|
||||
threshold: 0.85 # tag fires when sub-score >= threshold (multiple allowed)
|
||||
min_active_years: 2 # never tag someone with <2 active years (no history)
|
||||
|
||||
report:
|
||||
# Cast for make_report.py, in order: bridger, mentor, amplifier, near-miss.
|
||||
# Pinned so the report is reproducible — without this the script auto-picks the
|
||||
# current top scorer per tag, which changes with every weight tune or dump refresh.
|
||||
# Remove/empty the list to fall back to automatic selection.
|
||||
featured_author_ids:
|
||||
- A5113304257 # Jan Egger — top bridger
|
||||
- A5043495754 # Cornelius Deuschl — top mentor
|
||||
- A5007801159 # Jens Wiltfang — top amplifier
|
||||
- A5043360678 # Tabea M. G. Pakull — strong profile just below the tag line
|
||||
@@ -1,161 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
networks.py — materialize per-author ego-network documents for visualization.
|
||||
|
||||
The scores index answers "what did this person score"; the network index answers
|
||||
"who are they connected to and how" — the data a frontend needs to draw the
|
||||
ego-network figures (force layout, role colors, tooltips). The neighbor-neighbor
|
||||
edges that make graph shape readable (dense mesh = one community, spokes with gaps
|
||||
= brokered structural holes) come from works that do NOT include the ego, so they
|
||||
can only be materialized here, while the full graph is in memory — no request-time
|
||||
query can reconstruct them.
|
||||
|
||||
Doc shape (one per focal author, _id = <institution>_<author>):
|
||||
|
||||
nodes[] {id, name, role, inst, active_years, suspicious}
|
||||
role: ego | mentee | cohort | industry | external
|
||||
edges[] {a, b, w, n_works, cross, first_year, last_year}
|
||||
w = decayed collaboration strength; cross = mostly cross-institution
|
||||
ego{} small header duplicate (bucket, tags, sub_scores) so the network
|
||||
endpoint can render standalone
|
||||
totals total_coauthors, cohort_coauthors, shown
|
||||
|
||||
Node selection: the ego's strongest `max_nodes` co-authors by tie weight, with up
|
||||
to `max_forced_mentees` mentees force-included first — mentees' ties are decayed
|
||||
and team-size-divided, so a pure top-by-weight cut hides exactly the people the
|
||||
mentor score is about (empirically: a 100-mentee professor had zero mentees in his
|
||||
unforced top 42). Positions are NOT stored — the frontend's force layout
|
||||
(e.g. echarts `graph` series) lays out at render time.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from graph import Graph
|
||||
from metrics import is_suspicious_profile
|
||||
|
||||
|
||||
def build_network_docs(
|
||||
graph: Graph,
|
||||
metric_rows: dict[str, dict[str, Any]],
|
||||
scored_rows: list[dict[str, Any]],
|
||||
incident: dict[str, list],
|
||||
inst_by_author: dict[str, str],
|
||||
company_by_author_work: dict[str, dict[str, list[str]]],
|
||||
company_work_authors: dict[str, set[str]],
|
||||
max_nodes: int = 42,
|
||||
max_forced_mentees: int = 14,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""One visualization doc per focal author.
|
||||
|
||||
metric_rows must still carry the FULL `junior_ids` (pre-scoring; the scored
|
||||
rows' evidence list is capped). scored_rows supply the ego header fields.
|
||||
|
||||
Industry roles are TIE-LEVEL, not lifetime: a neighbour is marked `industry`
|
||||
only if a company affiliation of theirs appears on a work SHARED with the ego
|
||||
— matching what `industry_coauthor_share` counts. (The first version flagged
|
||||
anyone who ever had a company affiliation anywhere in the corpus, which
|
||||
painted predominantly-academic people orange over one dual affiliation from
|
||||
years ago, with a university name in the tooltip contradicting the colour.)
|
||||
The triggering company names ship on the node as `company_insts`, and
|
||||
`inst_by_author` should be the author's MOST FREQUENT institution so the
|
||||
default label matches reality.
|
||||
"""
|
||||
scored_by_id = {r["author_id"]: r for r in scored_rows}
|
||||
docs: list[dict[str, Any]] = []
|
||||
|
||||
for ego_id, mrow in metric_rows.items():
|
||||
srow = scored_by_id.get(ego_id)
|
||||
if srow is None:
|
||||
continue
|
||||
mentees = set(mrow.get("junior_ids") or [])
|
||||
ranked = sorted(
|
||||
incident.get(ego_id, []), key=lambda kv: kv[1].weight, reverse=True
|
||||
)
|
||||
|
||||
mentee_picks = [n for n, _ in ranked if n in mentees][:max_forced_mentees]
|
||||
forced = set(mentee_picks)
|
||||
others = [n for n, _ in ranked if n not in forced]
|
||||
selected = [ego_id] + mentee_picks + others[: max_nodes - len(mentee_picks)]
|
||||
idset = set(selected)
|
||||
|
||||
nodes = []
|
||||
for nid in selected:
|
||||
node = graph.nodes[nid]
|
||||
# company evidence ON WORKS SHARED WITH THE EGO only
|
||||
shared_companies: set[str] = set()
|
||||
for wid, names in (company_by_author_work.get(nid) or {}).items():
|
||||
if ego_id in company_work_authors.get(wid, ()):
|
||||
shared_companies.update(names)
|
||||
if nid == ego_id:
|
||||
role = "ego"
|
||||
elif nid in mentees:
|
||||
role = "mentee"
|
||||
elif shared_companies and not node.is_focal:
|
||||
role = "industry"
|
||||
elif node.is_focal:
|
||||
role = "cohort"
|
||||
else:
|
||||
role = "external"
|
||||
entry = {
|
||||
"id": nid,
|
||||
"name": node.display_name,
|
||||
"role": role,
|
||||
"inst": inst_by_author.get(nid, ""),
|
||||
"active_years": len(node.publication_years),
|
||||
"suspicious": is_suspicious_profile(node.publication_years),
|
||||
}
|
||||
if shared_companies:
|
||||
# the receipts for the industry colour (also kept on cohort/
|
||||
# mentee nodes so tooltips can show the industry link)
|
||||
entry["company_insts"] = sorted(shared_companies)
|
||||
nodes.append(entry)
|
||||
|
||||
# all corpus edges among the selected nodes — pair lookups against the
|
||||
# edge dict (~900 per ego), NOT a scan of the 5.8M-edge dict per ego
|
||||
edges = []
|
||||
for i, a in enumerate(selected):
|
||||
for b in selected[i + 1:]:
|
||||
e = graph.edges.get((a, b) if a < b else (b, a))
|
||||
if e is None:
|
||||
continue
|
||||
edges.append(
|
||||
{
|
||||
"a": a,
|
||||
"b": b,
|
||||
"w": round(e.weight, 3),
|
||||
"n_works": e.n_works,
|
||||
"cross": bool(
|
||||
e.weight > 0 and e.cross_inst_weight / e.weight > 0.5
|
||||
),
|
||||
"first_year": e.first_joint_year,
|
||||
"last_year": e.last_joint_year,
|
||||
}
|
||||
)
|
||||
|
||||
cohort_coauthors = sum(
|
||||
1 for n, _ in ranked if graph.nodes[n].is_focal
|
||||
)
|
||||
docs.append(
|
||||
{
|
||||
"author_id": ego_id,
|
||||
"display_name": srow.get("display_name"),
|
||||
"ego": {
|
||||
"career_bucket": srow.get("career_bucket"),
|
||||
"active_years": srow.get("active_years"),
|
||||
"n_works": srow.get("n_works"),
|
||||
"suspicious_profile": srow.get("suspicious_profile"),
|
||||
"tags": srow.get("tags", []),
|
||||
"sub_scores": srow.get("sub_scores", {}),
|
||||
"max_sub_score": srow.get("max_sub_score"),
|
||||
},
|
||||
"total_coauthors": len(ranked),
|
||||
"cohort_coauthors": cohort_coauthors,
|
||||
"mentee_count": len(mentees),
|
||||
"shown": len(selected) - 1,
|
||||
"shown_mentees": len(mentee_picks),
|
||||
"nodes": nodes,
|
||||
"edges": edges,
|
||||
}
|
||||
)
|
||||
return docs
|
||||
@@ -1,461 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Multipliers, drawn as networks</title>
|
||||
<style>
|
||||
:root {
|
||||
--surface: #fcfcfb;
|
||||
--surface-2: #f4f3f0;
|
||||
--ink: #0b0b0b;
|
||||
--ink-2: #52514e;
|
||||
--ink-3: #8a8983;
|
||||
--line: #e4e2dc;
|
||||
--ego: #e87ba4;
|
||||
--cohort: #2a78d6;
|
||||
--mentee: #1baf7a;
|
||||
--industry: #eb6834;
|
||||
--external: #b5b4ac;
|
||||
--bar: #2a78d6;
|
||||
--node-stroke: rgba(11,11,11,.35);
|
||||
color-scheme: light;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root:not([data-theme="light"]) {
|
||||
--surface: #1a1a19;
|
||||
--surface-2: #232322;
|
||||
--ink: #ffffff;
|
||||
--ink-2: #c3c2b7;
|
||||
--ink-3: #8a8983;
|
||||
--line: #3a3936;
|
||||
--ego: #d55181;
|
||||
--cohort: #3987e5;
|
||||
--mentee: #199e70;
|
||||
--industry: #d95926;
|
||||
--external: #55544f;
|
||||
--bar: #3987e5;
|
||||
--node-stroke: rgba(255,255,255,.35);
|
||||
color-scheme: dark;
|
||||
}
|
||||
}
|
||||
:root[data-theme="dark"] {
|
||||
--surface: #1a1a19;
|
||||
--surface-2: #232322;
|
||||
--ink: #ffffff;
|
||||
--ink-2: #c3c2b7;
|
||||
--ink-3: #8a8983;
|
||||
--line: #3a3936;
|
||||
--ego: #d55181;
|
||||
--cohort: #3987e5;
|
||||
--mentee: #199e70;
|
||||
--industry: #d95926;
|
||||
--external: #55544f;
|
||||
--bar: #3987e5;
|
||||
--node-stroke: rgba(255,255,255,.35);
|
||||
color-scheme: dark;
|
||||
}
|
||||
:root[data-theme="light"] {
|
||||
--surface: #fcfcfb;
|
||||
--surface-2: #f4f3f0;
|
||||
--ink: #0b0b0b;
|
||||
--ink-2: #52514e;
|
||||
--ink-3: #8a8983;
|
||||
--line: #e4e2dc;
|
||||
--ego: #e87ba4;
|
||||
--cohort: #2a78d6;
|
||||
--mentee: #1baf7a;
|
||||
--industry: #eb6834;
|
||||
--external: #b5b4ac;
|
||||
--bar: #2a78d6;
|
||||
--node-stroke: rgba(11,11,11,.35);
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--surface);
|
||||
color: var(--ink);
|
||||
font-family: Charter, Georgia, 'Times New Roman', serif;
|
||||
line-height: 1.55;
|
||||
margin: 0;
|
||||
}
|
||||
.wrap { max-width: 1160px; margin: 0 auto; padding: 40px 24px 80px; }
|
||||
|
||||
header.page { max-width: 70ch; margin-bottom: 12px; }
|
||||
.eyebrow {
|
||||
font-family: -apple-system, 'Segoe UI', sans-serif;
|
||||
font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
|
||||
color: var(--ink-3); margin: 0 0 10px;
|
||||
}
|
||||
h1 { font-size: 34px; line-height: 1.15; margin: 0 0 12px; text-wrap: balance; font-weight: 700; }
|
||||
.lede { color: var(--ink-2); font-size: 16.5px; margin: 0; }
|
||||
|
||||
.legend {
|
||||
position: sticky; top: 0; z-index: 5;
|
||||
background: var(--surface);
|
||||
border-block: 1px solid var(--line);
|
||||
margin: 28px 0 0;
|
||||
padding: 10px 2px;
|
||||
display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center;
|
||||
font-family: -apple-system, 'Segoe UI', sans-serif; font-size: 12.5px; color: var(--ink-2);
|
||||
}
|
||||
.legend .li { display: inline-flex; align-items: center; gap: 7px; }
|
||||
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--node-stroke); flex: none; }
|
||||
.dot.ego { outline: 2px solid var(--ink); outline-offset: 1.5px; }
|
||||
.edge-sample { width: 26px; height: 0; border-top: 2px solid var(--ink-3); flex: none; }
|
||||
.edge-sample.dashed { border-top-style: dashed; }
|
||||
|
||||
section.case { margin-top: 52px; }
|
||||
.case-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 14px; margin-bottom: 4px; }
|
||||
.case-eyebrow { font-family: -apple-system,'Segoe UI',sans-serif; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; margin: 0; }
|
||||
h2 { font-size: 26px; margin: 0; font-weight: 700; }
|
||||
.pill {
|
||||
font-family: -apple-system,'Segoe UI',sans-serif; font-size: 11.5px; font-weight: 600;
|
||||
padding: 2.5px 10px; border-radius: 999px; letter-spacing: .04em;
|
||||
border: 1px solid var(--line); color: var(--ink-2); background: var(--surface-2);
|
||||
}
|
||||
.pill.tag { color: var(--surface); border: none; }
|
||||
.meta-line { font-family: -apple-system,'Segoe UI',sans-serif; font-size: 13px; color: var(--ink-3); margin: 2px 0 18px; }
|
||||
|
||||
.case-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 26px; align-items: start; }
|
||||
@media (max-width: 900px) { .case-grid { grid-template-columns: 1fr; } }
|
||||
|
||||
.netbox { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); overflow: hidden; }
|
||||
.netbox svg { display: block; width: 100%; height: auto; }
|
||||
.netfoot { font-family: -apple-system,'Segoe UI',sans-serif; font-size: 12px; color: var(--ink-3); padding: 8px 12px; border-top: 1px solid var(--line); }
|
||||
|
||||
.panel { display: flex; flex-direction: column; gap: 18px; }
|
||||
.panel h3 {
|
||||
font-family: -apple-system,'Segoe UI',sans-serif; font-size: 11px; letter-spacing: .12em;
|
||||
text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; font-weight: 600;
|
||||
}
|
||||
.scorebar { display: grid; grid-template-columns: 74px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 7px;
|
||||
font-family: -apple-system,'Segoe UI',sans-serif; font-size: 12.5px; }
|
||||
.scorebar .nm { color: var(--ink-2); }
|
||||
.scorebar .val { font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); }
|
||||
.track { position: relative; height: 10px; background: var(--surface-2); border-radius: 4px; border: 1px solid var(--line); }
|
||||
.fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px 3px 3px 4px; background: var(--bar); opacity: .55; }
|
||||
.fill.lead { opacity: 1; }
|
||||
.thresh { position: absolute; top: -3px; bottom: -3px; left: 85%; width: 0; border-left: 2px dashed var(--ink-3); }
|
||||
|
||||
table.mx { border-collapse: collapse; width: 100%; font-family: -apple-system,'Segoe UI',sans-serif; font-size: 12.5px; }
|
||||
table.mx th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 8px 0 4px; }
|
||||
table.mx td { padding: 3.5px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
|
||||
table.mx td.num { font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); white-space: nowrap; }
|
||||
table.mx td.num.hot { font-weight: 700; }
|
||||
|
||||
.reading { max-width: 72ch; margin-top: 18px; font-size: 15.5px; color: var(--ink-2); }
|
||||
.reading strong { color: var(--ink); }
|
||||
|
||||
.tooltip {
|
||||
position: fixed; pointer-events: none; z-index: 20; display: none;
|
||||
background: var(--ink); color: var(--surface);
|
||||
font-family: -apple-system,'Segoe UI',sans-serif; font-size: 12px; line-height: 1.45;
|
||||
padding: 8px 11px; border-radius: 7px; max-width: 260px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
|
||||
}
|
||||
.tooltip .t-name { font-weight: 700; }
|
||||
.tooltip .t-dim { opacity: .75; }
|
||||
|
||||
footer.page { margin-top: 60px; border-top: 1px solid var(--line); padding-top: 16px;
|
||||
font-family: -apple-system,'Segoe UI',sans-serif; font-size: 12.5px; color: var(--ink-3); max-width: 78ch; }
|
||||
svg .node { cursor: pointer; }
|
||||
#themeToggle {
|
||||
position: fixed; top: 14px; right: 14px; z-index: 30;
|
||||
font-family: -apple-system,'Segoe UI',sans-serif; font-size: 12px; padding: 6px 12px;
|
||||
border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
|
||||
color: var(--ink-2); cursor: pointer;
|
||||
}
|
||||
#themeToggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="wrap">
|
||||
<header class="page">
|
||||
<p class="eyebrow" id="topline">Smart-Guide · Multiplier detection</p>
|
||||
<h1>Four researchers, drawn as the networks that scored them</h1>
|
||||
<p class="lede">
|
||||
Each figure shows one person (ringed) and their strongest co-authors, with every
|
||||
collaboration the corpus records <em>among</em> those co-authors. The shape is the
|
||||
metric: spokes that don't touch are brokered structural holes; a dense mesh is a
|
||||
tight community; green marks the juniors a mentor brought up; orange marks a
|
||||
company link on the works shared with that person. Hover any node for its details.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div class="legend" id="legend">
|
||||
<span class="li"><span class="dot ego" style="background:var(--ego)"></span>the person (ego)</span>
|
||||
<span class="li"><span class="dot" style="background:var(--cohort)"></span>cohort co-author</span>
|
||||
<span class="li"><span class="dot" style="background:var(--mentee)"></span>their mentee (junior at first joint paper)</span>
|
||||
<span class="li"><span class="dot" style="background:var(--industry)"></span>company link on works shared with the ego</span>
|
||||
<span class="li"><span class="dot" style="background:var(--external)"></span>external academic</span>
|
||||
<span class="li"><span class="edge-sample"></span>collaboration (width = decayed strength)</span>
|
||||
<span class="li"><span class="edge-sample dashed"></span>mostly cross-institution</span>
|
||||
<span class="li">node size = active years</span>
|
||||
</div>
|
||||
|
||||
<div id="cases"></div>
|
||||
|
||||
<footer class="page">
|
||||
Data: OpenAlex works of the institution cohort (works ≤ 50 authors enter the graph;
|
||||
edge strength decays 0.8/year), read from the <code>multiplicators_v1</code> and
|
||||
<code>multiplicator_networks_v1</code> indices. Networks show each ego's strongest
|
||||
co-authors — totals are given per figure. Scores are percentile-normalized within
|
||||
career buckets; tag threshold 0.85. Config <span id="cfg"></span>, computed
|
||||
<span id="ts"></span>. Mentee marking uses the seniority-gap rule and is restricted
|
||||
to cohort members; external co-authors' histories are truncated to shared works, so
|
||||
their node size is a lower bound. An orange node means a company affiliation appeared
|
||||
on a work shared with the ego — the company is named in the tooltip.
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<div class="tooltip" id="tip"></div>
|
||||
<button id="themeToggle" aria-label="Toggle color theme">theme</button>
|
||||
|
||||
<script>
|
||||
const DATA = __DATA__;
|
||||
|
||||
const ROLE = { ego:'--ego', cohort:'--cohort', mentee:'--mentee', industry:'--industry', external:'--external' };
|
||||
const ORDER = ['bridger','mentor','amplifier','example'];
|
||||
const EYEBROW = {
|
||||
bridger: ['Case 1 — the bridger archetype', '--cohort'],
|
||||
mentor: ['Case 2 — the mentor archetype', '--mentee'],
|
||||
amplifier:['Case 3 — the amplifier archetype', '--industry'],
|
||||
example: ['Case 4 — a strong profile below the tag line', '--ego'],
|
||||
};
|
||||
const ROLE_LABEL = {
|
||||
ego: 'This case’s subject',
|
||||
cohort: 'Cohort co-author',
|
||||
mentee: 'Mentee — junior at first joint paper',
|
||||
industry: 'Company link on shared works',
|
||||
external: 'External academic',
|
||||
};
|
||||
|
||||
const fmt = (v, d=2) => v == null ? '—' : (+v).toFixed(d);
|
||||
const pct = v => v == null ? '—' : Math.round(v*100) + '%';
|
||||
|
||||
function readingFor(kind, r, d) {
|
||||
const p = r.percentiles || {};
|
||||
if (kind === 'bridger') return `
|
||||
<strong>${r.display_name}</strong> holds the cohort's highest bridger score
|
||||
(<strong>${fmt(r.sub_scores.bridger,3)}</strong>). The picture explains it: the
|
||||
${d.total_coauthors} co-authors split into groups that barely touch except through
|
||||
the ego — brokerage ${fmt(r.brokerage,2)} (${pct(p.brokerage)} of the career
|
||||
bucket), ${pct(r.cross_institution_share)} of collaboration weight crosses
|
||||
institutions (dashed edges), and betweenness sits at the ${pct(p.betweenness)}
|
||||
percentile. Where the mentor's figure below is one dense mesh, this one is spokes
|
||||
and gaps — the gaps <em>are</em> the structural holes.`;
|
||||
if (kind === 'mentor') return `
|
||||
<strong>${r.display_name}</strong> tops the mentor ranking
|
||||
(<strong>${fmt(r.sub_scores.mentor,3)}</strong>) with ${r.juniors_mentored} cohort
|
||||
co-authors who were Early-career at their first joint paper while the ego was
|
||||
already Established — the green nodes — plus ${r.last_author_with_junior_first}
|
||||
papers in the classic supervision configuration (ego last author, a junior first).
|
||||
The mesh is dense: this is one connected group, the opposite structure of the
|
||||
bridger above. Only the ${d.shown} strongest ties of ${d.total_coauthors} are drawn.`;
|
||||
if (kind === 'amplifier') return `
|
||||
<strong>${r.display_name}</strong> tops the amplifier ranking
|
||||
(<strong>${fmt(r.sub_scores.amplifier,3)}</strong>) on converging independent
|
||||
channels: ${r.patent_count} high-confidence patent${r.patent_count===1?'':'s'},
|
||||
${r.cordis_eu_projects} EU project${r.cordis_eu_projects===1?'':'s'} via DOI
|
||||
overlap, ${r.news_mentions} press mention${r.news_mentions===1?'':'s'}, and a
|
||||
shrunk industry co-authorship share of ${fmt(r.industry_coauthor_share_shrunk,2)}
|
||||
(${pct(p.industry_coauthor_share_shrunk)} of the bucket). With
|
||||
${d.total_coauthors.toLocaleString('en')} total co-authors only the strongest
|
||||
${d.shown} are drawn — orange nodes carry a company affiliation on the shared work.`;
|
||||
const best = Math.max(...Object.values(r.sub_scores));
|
||||
const bestName = Object.entries(r.sub_scores).sort((a,b)=>b[1]-a[1])[0][0];
|
||||
const gated = best >= 0.85;
|
||||
return `
|
||||
<strong>${r.display_name}</strong> is the system's honest edge case: the
|
||||
highest-scoring person who still carries <strong>no tag</strong>. The ${bestName}
|
||||
sub-score reaches ${fmt(best,3)} ${gated
|
||||
? `— <em>above</em> the 0.85 line. The tag is withheld by the
|
||||
<code>min_active_years</code> guard: ${r.active_years} active
|
||||
year${r.active_years===1?'':'s'} is too thin a history to rank on, and a
|
||||
high score on one year is the signature of a <em>split</em> OpenAlex profile
|
||||
— a fragment of someone's record carrying a share of their patents, press or
|
||||
industry ties. The guard catches what <code>suspicious_profile</code> cannot:
|
||||
that flag detects merged identities, not split ones.`
|
||||
: `— just under the 0.85 line, on ${r.active_years} active
|
||||
year${r.active_years===1?'':'s'}. Thresholds are meant to surface the top of
|
||||
each bucket, and this profile sits one weight-tune away from either side.`}
|
||||
Either way it is the case coaches should see: ${d.total_coauthors} co-authors,
|
||||
brokerage ${fmt(r.brokerage,2)} (${pct(p.brokerage)} of the bucket),
|
||||
${pct(r.cross_institution_share)} cross-institution weight — a real profile that
|
||||
the ranking deliberately holds back.`;
|
||||
}
|
||||
|
||||
function svgNet(d) {
|
||||
const W = 760, H = 560, ns = 'http://www.w3.org/2000/svg';
|
||||
const svg = document.createElementNS(ns, 'svg');
|
||||
svg.setAttribute('viewBox', `0 0 ${W} ${H}`);
|
||||
svg.setAttribute('role', 'img');
|
||||
svg.setAttribute('aria-label', `Co-author network of ${d.score_row.display_name}`);
|
||||
const byId = {};
|
||||
d.nodes.forEach(n => byId[n.id] = n);
|
||||
const ego = d.nodes[0];
|
||||
const wmax = Math.max(...d.edges.map(e => e.w), 0.01);
|
||||
|
||||
const eg = document.createElementNS(ns, 'g');
|
||||
d.edges.forEach(e => {
|
||||
const a = byId[e.a], b = byId[e.b];
|
||||
if (!a || !b) return;
|
||||
const ln = document.createElementNS(ns, 'line');
|
||||
ln.setAttribute('x1', a.x); ln.setAttribute('y1', a.y);
|
||||
ln.setAttribute('x2', b.x); ln.setAttribute('y2', b.y);
|
||||
const touchesEgo = (e.a === ego.id || e.b === ego.id);
|
||||
ln.setAttribute('stroke', 'currentColor');
|
||||
ln.setAttribute('stroke-opacity', touchesEgo ? 0.42 : 0.16);
|
||||
ln.setAttribute('stroke-width', Math.max(0.6, Math.min(4.5, 2.8*Math.sqrt(e.w/wmax))));
|
||||
if (e.cross) ln.setAttribute('stroke-dasharray', '4 3');
|
||||
eg.appendChild(ln);
|
||||
});
|
||||
eg.setAttribute('color', 'var(--ink-3)');
|
||||
svg.appendChild(eg);
|
||||
|
||||
const edgeToEgo = {};
|
||||
d.edges.forEach(e => {
|
||||
if (e.a === ego.id) edgeToEgo[e.b] = e;
|
||||
if (e.b === ego.id) edgeToEgo[e.a] = e;
|
||||
});
|
||||
|
||||
const ng = document.createElementNS(ns, 'g');
|
||||
d.nodes.forEach(n => {
|
||||
const c = document.createElementNS(ns, 'circle');
|
||||
const isEgo = n.role === 'ego';
|
||||
const r = isEgo ? 13 : Math.max(4, Math.min(9, 3 + 1.1*Math.sqrt(n.active_years)));
|
||||
c.setAttribute('class', 'node');
|
||||
c.setAttribute('cx', n.x); c.setAttribute('cy', n.y); c.setAttribute('r', r);
|
||||
c.setAttribute('fill', `var(${ROLE[n.role]})`);
|
||||
c.setAttribute('stroke', isEgo ? 'var(--ink)' : 'var(--node-stroke)');
|
||||
c.setAttribute('stroke-width', isEgo ? 2.5 : 1);
|
||||
c.addEventListener('pointerenter', ev => {
|
||||
const e = edgeToEgo[n.id];
|
||||
showTip(ev, `
|
||||
<div class="t-name">${n.name || n.id}</div>
|
||||
<div>${ROLE_LABEL[n.role] || n.role}</div>
|
||||
${n.inst ? `<div class="t-dim">${n.inst}</div>` : ''}
|
||||
${n.company_insts ? `<div>Industry link: ${n.company_insts.join(', ')}</div>` : ''}
|
||||
<div class="t-dim">${n.active_years} active year${n.active_years===1?'':'s'}${
|
||||
e ? ` · tie strength ${e.w.toFixed(2)} · ${e.n} joint work${e.n===1?'':'s'} · since ${e.y0}` : ''}</div>`);
|
||||
});
|
||||
c.addEventListener('pointermove', moveTip);
|
||||
c.addEventListener('pointerleave', hideTip);
|
||||
ng.appendChild(c);
|
||||
});
|
||||
svg.appendChild(ng);
|
||||
|
||||
const label = document.createElementNS(ns, 'text');
|
||||
label.setAttribute('x', ego.x); label.setAttribute('y', ego.y + 30);
|
||||
label.setAttribute('text-anchor', 'middle');
|
||||
label.setAttribute('style', 'font-family:-apple-system,Segoe UI,sans-serif;font-size:12.5px;font-weight:700;fill:var(--ink);paint-order:stroke;stroke:var(--surface);stroke-width:3px;');
|
||||
label.textContent = ego.name;
|
||||
svg.appendChild(label);
|
||||
return svg;
|
||||
}
|
||||
|
||||
const tip = document.getElementById('tip');
|
||||
function showTip(ev, html) { tip.innerHTML = html; tip.style.display = 'block'; moveTip(ev); }
|
||||
function moveTip(ev) {
|
||||
const pad = 14;
|
||||
let x = ev.clientX + pad, y = ev.clientY + pad;
|
||||
const r = tip.getBoundingClientRect();
|
||||
if (x + r.width > innerWidth - 8) x = ev.clientX - r.width - pad;
|
||||
if (y + r.height > innerHeight - 8) y = ev.clientY - r.height - pad;
|
||||
tip.style.left = x + 'px'; tip.style.top = y + 'px';
|
||||
}
|
||||
function hideTip() { tip.style.display = 'none'; }
|
||||
|
||||
function metricRows(r) {
|
||||
const p = r.percentiles || {};
|
||||
const groups = [
|
||||
['Bridging', [
|
||||
['Betweenness', fmt(r.betweenness, r.betweenness && r.betweenness < 0.01 ? 4 : 3), p.betweenness],
|
||||
['Brokerage (1−constraint)', fmt(r.brokerage), p.brokerage],
|
||||
['Field entropy', fmt(r.field_entropy), p.field_entropy],
|
||||
['Cross-institution share', fmt(r.cross_institution_share), p.cross_institution_share],
|
||||
]],
|
||||
['Mentoring', [
|
||||
['Juniors mentored', r.juniors_mentored, p.juniors_mentored],
|
||||
['Last-author + junior first', r.last_author_with_junior_first, p.last_author_with_junior_first],
|
||||
['Mentoring rate', fmt(r.mentoring_rate), p.mentoring_rate],
|
||||
]],
|
||||
['Amplification', [
|
||||
['Industry share (shrunk)', fmt(r.industry_coauthor_share_shrunk), p.industry_coauthor_share_shrunk],
|
||||
['Patents (high-confidence)', r.patent_count, p.patent_count],
|
||||
['EU projects (DOI join)', r.cordis_eu_projects, p.cordis_eu_projects],
|
||||
['News mentions', r.news_mentions, p.news_mentions],
|
||||
]],
|
||||
];
|
||||
let html = '<table class="mx"><tr><th>Metric</th><th style="text-align:right">Raw</th><th style="text-align:right">Bucket pctl</th></tr>';
|
||||
for (const [g, rows] of groups) {
|
||||
html += `<tr><td colspan="3" style="border-top:none;padding-top:10px;font-weight:600;color:var(--ink-3);font-size:11px;letter-spacing:.06em;text-transform:uppercase">${g}</td></tr>`;
|
||||
for (const [nm, raw, pc] of rows) {
|
||||
const hot = pc != null && pc >= 0.9;
|
||||
html += `<tr><td>${nm}</td><td class="num">${raw == null ? '—' : raw}</td><td class="num${hot?' hot':''}">${pc==null?'—':pct(pc)}</td></tr>`;
|
||||
}
|
||||
}
|
||||
return html + '</table>';
|
||||
}
|
||||
|
||||
const container = document.getElementById('cases');
|
||||
let firstCase = null;
|
||||
for (const kind of ORDER) {
|
||||
const key = Object.keys(DATA).find(k => DATA[k].kind === kind);
|
||||
if (!key) continue;
|
||||
const d = DATA[key], r = d.score_row;
|
||||
if (!firstCase) firstCase = d;
|
||||
const [eyebrow, hue] = EYEBROW[kind];
|
||||
const lead = Object.entries(r.sub_scores).sort((a,b)=>b[1]-a[1])[0][0];
|
||||
|
||||
const sec = document.createElement('section');
|
||||
sec.className = 'case';
|
||||
sec.innerHTML = `
|
||||
<p class="case-eyebrow" style="color:var(${hue})">${eyebrow}</p>
|
||||
<div class="case-head">
|
||||
<h2>${r.display_name}</h2>
|
||||
${(r.tags||[]).map(t => `<span class="pill tag" style="background:var(${hue})">${t}</span>`).join('')}
|
||||
${(r.tags||[]).length === 0 ? '<span class="pill">no tag</span>' : ''}
|
||||
<span class="pill">${r.career_bucket} · ${r.active_years} active years</span>
|
||||
${r.suspicious_profile ? '<span class="pill">low-confidence profile</span>' : ''}
|
||||
</div>
|
||||
<p class="meta-line">${r.n_works} works · ${d.total_coauthors.toLocaleString('en')} co-authors
|
||||
(strongest ${d.shown} drawn) · author ${r.author_id}</p>
|
||||
<div class="case-grid">
|
||||
<div class="netbox">
|
||||
<div class="svg-slot"></div>
|
||||
<div class="netfoot">Edges among the drawn co-authors are the corpus's actual
|
||||
collaborations — their density (or absence) is what constraint/brokerage measures.</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div>
|
||||
<h3>Sub-scores <span style="letter-spacing:0;text-transform:none">(dashed line = 0.85 tag threshold)</span></h3>
|
||||
${['bridger','mentor','amplifier'].map(s => `
|
||||
<div class="scorebar">
|
||||
<span class="nm">${s}</span>
|
||||
<span class="track"><span class="fill${s===lead?' lead':''}" style="width:${(r.sub_scores[s]*100).toFixed(1)}%"></span><span class="thresh"></span></span>
|
||||
<span class="val">${fmt(r.sub_scores[s],3)}</span>
|
||||
</div>`).join('')}
|
||||
</div>
|
||||
<div>${metricRows(r)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="reading">${readingFor(kind, r, d)}</p>`;
|
||||
sec.querySelector('.svg-slot').appendChild(svgNet(d));
|
||||
container.appendChild(sec);
|
||||
}
|
||||
if (firstCase) {
|
||||
document.getElementById('cfg').textContent = firstCase.config_hash || '—';
|
||||
document.getElementById('ts').textContent = firstCase.computed_at || '—';
|
||||
}
|
||||
|
||||
document.getElementById('themeToggle').addEventListener('click', () => {
|
||||
const root = document.documentElement;
|
||||
const dark = root.getAttribute('data-theme') === 'dark' ||
|
||||
(!root.getAttribute('data-theme') && matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
root.setAttribute('data-theme', dark ? 'light' : 'dark');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +0,0 @@
|
||||
httpx>=0.27
|
||||
python-dotenv>=1.0
|
||||
polars>=1.0
|
||||
pyyaml>=6.0
|
||||
|
||||
# test-only (never in the service image):
|
||||
# pip install pytest networkx
|
||||
@@ -1,135 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
scoring.py — normalization, sub-scores and tags (M1, Stage F).
|
||||
|
||||
Procedure (per plan §3/§6):
|
||||
1. Bucket every focal author by career stage from `active_years`
|
||||
(Early/Emerging/Established/Senior — thresholds mirror inse/persons/logic.py).
|
||||
2. Percentile-rank every raw metric WITHIN its bucket, so early-career people
|
||||
compete against early-career people. The M0 spike found median active_years = 4:
|
||||
half the cohort is "Early", and institution-wide percentiles would simply rank
|
||||
seniority.
|
||||
3. Sub-scores = weighted mean of the percentiles (weights from multiplicators.yaml).
|
||||
4. Tag anyone >= tags.threshold on a sub-score (multiple tags allowed).
|
||||
|
||||
Raw values, percentiles, and sub-scores are ALL persisted — coaches and calibration
|
||||
both need the intermediates. None/NaN raw values are excluded from percentile ranking
|
||||
and contribute 0 to the weighted mean (weight is redistributed over present metrics).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def load_config(path: str) -> dict[str, Any]:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
config = yaml.safe_load(f)
|
||||
config["_config_hash"] = hashlib.sha256(
|
||||
json.dumps(config, sort_keys=True, default=str).encode()
|
||||
).hexdigest()[:12]
|
||||
return config
|
||||
|
||||
|
||||
def career_bucket(active_years: int, thresholds: list[int], names: list[str]) -> str:
|
||||
"""Bucket by active_years. thresholds=[4,9,14] -> Early/Emerging/Established/Senior."""
|
||||
for threshold, name in zip(thresholds, names):
|
||||
if active_years <= threshold:
|
||||
return name
|
||||
return names[len(thresholds)]
|
||||
|
||||
|
||||
def percentile_ranks(values: dict[str, float | None]) -> dict[str, float]:
|
||||
"""Mean-rank percentiles in (0, 1] over the non-None values.
|
||||
|
||||
Ties share their mean rank, so a metric where most values are 0 (e.g.
|
||||
juniors_mentored for Early authors) does not hand everyone a high percentile.
|
||||
"""
|
||||
present = [(aid, v) for aid, v in values.items() if v is not None]
|
||||
if not present:
|
||||
return {}
|
||||
present.sort(key=lambda kv: kv[1])
|
||||
n = len(present)
|
||||
ranks: dict[str, float] = {}
|
||||
i = 0
|
||||
while i < n:
|
||||
j = i
|
||||
while j + 1 < n and present[j + 1][1] == present[i][1]:
|
||||
j += 1
|
||||
mean_rank = (i + j) / 2 + 1 # 1-based mean rank of the tie group
|
||||
for k in range(i, j + 1):
|
||||
ranks[present[k][0]] = mean_rank / n
|
||||
i = j + 1
|
||||
return ranks
|
||||
|
||||
|
||||
def score_rows(
|
||||
metric_rows: dict[str, dict[str, Any]], config: dict[str, Any]
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Turn raw metric rows into scored, tagged, bucket-normalized output rows."""
|
||||
career_cfg = config["career"]
|
||||
weights: dict[str, dict[str, float]] = config["weights"]
|
||||
tag_threshold: float = config["tags"]["threshold"]
|
||||
min_active_years: int = config["tags"].get("min_active_years", 0)
|
||||
|
||||
# 1. bucket assignment
|
||||
buckets: dict[str, list[str]] = {}
|
||||
for aid, row in metric_rows.items():
|
||||
bucket = career_bucket(
|
||||
row["active_years"], career_cfg["buckets"], career_cfg["bucket_names"]
|
||||
)
|
||||
row["career_bucket"] = bucket
|
||||
buckets.setdefault(bucket, []).append(aid)
|
||||
|
||||
# 2. within-bucket percentiles for every metric used by any sub-score
|
||||
metric_names = sorted({m for w in weights.values() for m in w})
|
||||
percentiles: dict[str, dict[str, float]] = {aid: {} for aid in metric_rows}
|
||||
for bucket_members in buckets.values():
|
||||
for metric in metric_names:
|
||||
values = {
|
||||
aid: metric_rows[aid].get(metric)
|
||||
for aid in bucket_members
|
||||
if isinstance(metric_rows[aid].get(metric), (int, float))
|
||||
}
|
||||
for aid, pctl in percentile_ranks(values).items():
|
||||
percentiles[aid][metric] = pctl
|
||||
|
||||
# 3+4. weighted sub-scores and tags
|
||||
out: list[dict[str, Any]] = []
|
||||
for aid, row in metric_rows.items():
|
||||
sub_scores: dict[str, float] = {}
|
||||
for sub, metric_weights in weights.items():
|
||||
total_weight = 0.0
|
||||
acc = 0.0
|
||||
for metric, weight in metric_weights.items():
|
||||
pctl = percentiles[aid].get(metric)
|
||||
if pctl is not None:
|
||||
acc += weight * pctl
|
||||
total_weight += weight
|
||||
sub_scores[sub] = round(acc / total_weight, 4) if total_weight > 0 else 0.0
|
||||
|
||||
tags = (
|
||||
[s for s, v in sub_scores.items() if v >= tag_threshold]
|
||||
if row["active_years"] >= min_active_years
|
||||
else []
|
||||
)
|
||||
|
||||
out.append(
|
||||
{
|
||||
**{k: v for k, v in row.items() if k != "junior_ids"},
|
||||
"percentiles": {
|
||||
m: round(p, 4) for m, p in percentiles[aid].items()
|
||||
},
|
||||
"sub_scores": sub_scores,
|
||||
"tags": tags,
|
||||
"max_sub_score": max(sub_scores.values()) if sub_scores else 0.0,
|
||||
"evidence": {"junior_ids": row.get("junior_ids", [])[:25]},
|
||||
"config_hash": config["_config_hash"],
|
||||
}
|
||||
)
|
||||
|
||||
out.sort(key=lambda r: r["max_sub_score"], reverse=True)
|
||||
return out
|
||||
@@ -1,232 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
signals.py — M3 amplifier signal joins: patents, news, EU CORDIS projects.
|
||||
|
||||
Link quality differs per source and dictates how each is used (plan §4):
|
||||
|
||||
PATENTS org_patents.matched_authors carries real OpenAlex author IDs with a
|
||||
doc-level match_type. Only {institution, both} count toward the score;
|
||||
name-only matches are kept as a separate evidence count.
|
||||
NEWS aktuell_postproc holds LLM-extracted person names. Matching is
|
||||
normalized-exact (casefold + diacritic fold): "René Müller" == "rene
|
||||
muller". A normalized name shared by MULTIPLE cohort authors is skipped
|
||||
entirely (precision over recall) — crediting the wrong person is worse
|
||||
than missing a mention. Low YAML weight by design.
|
||||
CORDIS DOI-overlap join (no name matching): the author's work DOIs from the
|
||||
extract intersected with cordis_eu_*_publications DOIs -> distinct
|
||||
project IDs per author.
|
||||
|
||||
All functions return plain dict[author_short_id, count] and are independent of the
|
||||
graph/scoring modules.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import unicodedata
|
||||
from collections import defaultdict
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
|
||||
from extract import INSE_KEY, INSE_URL, es_search
|
||||
|
||||
PAGE_SIZE = 1000
|
||||
DOI_BATCH = 500
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Patents — org_patents (already author-ID-linked by index_org_patents.py)
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def patent_counts(
|
||||
client: httpx.Client,
|
||||
institution_short_id: str,
|
||||
scored_match_types: tuple[str, ...] = ("institution", "both"),
|
||||
) -> tuple[dict[str, int], dict[str, int]]:
|
||||
"""Per-author patent counts from org_patents.
|
||||
|
||||
Returns (scored, name_only): scored counts only docs whose match_type is in
|
||||
`scored_match_types`; name_only is kept as evidence and never enters the score.
|
||||
"""
|
||||
scored: dict[str, int] = defaultdict(int)
|
||||
name_only: dict[str, int] = defaultdict(int)
|
||||
search_after = None
|
||||
while True:
|
||||
body: dict[str, Any] = {
|
||||
"size": PAGE_SIZE,
|
||||
"_source": ["match_type", "matched_authors.openalex_author_id"],
|
||||
"query": {"term": {"institution_id": institution_short_id}},
|
||||
"sort": [{"patent_id": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
result = es_search(client, INSE_URL, INSE_KEY, "org_patents", body)
|
||||
hits = result["hits"]["hits"]
|
||||
if not hits:
|
||||
break
|
||||
for hit in hits:
|
||||
src = hit["_source"]
|
||||
target = scored if src.get("match_type") in scored_match_types else name_only
|
||||
for author in src.get("matched_authors") or []:
|
||||
aid = author.get("openalex_author_id")
|
||||
if aid:
|
||||
target[aid] += 1
|
||||
search_after = hits[-1]["sort"]
|
||||
return dict(scored), dict(name_only)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# News — aktuell_postproc (LLM-extracted names, normalized-exact match)
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def normalize_name(name: str) -> str:
|
||||
"""casefold + strip diacritics + collapse whitespace ("René Müller" -> "rene muller")."""
|
||||
decomposed = unicodedata.normalize("NFKD", name)
|
||||
stripped = "".join(c for c in decomposed if not unicodedata.combining(c))
|
||||
return " ".join(stripped.casefold().split())
|
||||
|
||||
|
||||
def news_mention_counts(
|
||||
client: httpx.Client,
|
||||
display_names: dict[str, str],
|
||||
require_relevant: bool = True,
|
||||
) -> tuple[dict[str, int], int]:
|
||||
"""Per-author news mention counts.
|
||||
|
||||
display_names: author_short_id -> display_name for the whole cohort.
|
||||
Returns (counts, ambiguous_names_skipped). Names that normalize identically for
|
||||
more than one cohort author are skipped entirely.
|
||||
"""
|
||||
by_norm: dict[str, list[str]] = defaultdict(list)
|
||||
for aid, name in display_names.items():
|
||||
if name:
|
||||
by_norm[normalize_name(name)].append(aid)
|
||||
ambiguous = {norm for norm, aids in by_norm.items() if len(aids) > 1}
|
||||
|
||||
counts: dict[str, int] = defaultdict(int)
|
||||
search_after = None
|
||||
while True:
|
||||
body: dict[str, Any] = {
|
||||
"size": PAGE_SIZE,
|
||||
"_source": ["authors", "relevant"],
|
||||
"query": {"exists": {"field": "authors"}},
|
||||
"sort": [{"news_id.keyword": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
result = es_search(client, INSE_URL, INSE_KEY, "aktuell_postproc", body)
|
||||
hits = result["hits"]["hits"]
|
||||
if not hits:
|
||||
break
|
||||
for hit in hits:
|
||||
src = hit["_source"]
|
||||
if require_relevant and not src.get("relevant"):
|
||||
continue
|
||||
for name in src.get("authors") or []:
|
||||
norm = normalize_name(name)
|
||||
if norm in ambiguous:
|
||||
continue
|
||||
aids = by_norm.get(norm)
|
||||
if aids:
|
||||
counts[aids[0]] += 1
|
||||
search_after = hits[-1]["sort"]
|
||||
return dict(counts), len(ambiguous)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# EU CORDIS — DOI-overlap join
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def normalize_doi(doi: str | None) -> str | None:
|
||||
if not doi:
|
||||
return None
|
||||
doi = doi.strip().casefold()
|
||||
for prefix in ("https://doi.org/", "http://doi.org/", "doi.org/", "doi:"):
|
||||
if doi.startswith(prefix):
|
||||
doi = doi[len(prefix):]
|
||||
return doi or None
|
||||
|
||||
|
||||
def cordis_project_counts(
|
||||
client: httpx.Client,
|
||||
dois_by_author: dict[str, set[str]],
|
||||
) -> dict[str, int]:
|
||||
"""Distinct CORDIS project count per author via DOI overlap.
|
||||
|
||||
dois_by_author values must already be normalized (normalize_doi).
|
||||
"""
|
||||
all_dois = sorted({d for dois in dois_by_author.values() for d in dois})
|
||||
projects_by_doi: dict[str, set[str]] = defaultdict(set)
|
||||
|
||||
for start in range(0, len(all_dois), DOI_BATCH):
|
||||
batch = all_dois[start : start + DOI_BATCH]
|
||||
# NOT a terms query: 21% of CORDIS DOIs contain uppercase, and `terms` on a
|
||||
# keyword field is case-sensitive. Per-term case_insensitive matching instead.
|
||||
result = es_search(
|
||||
client, INSE_URL, INSE_KEY, "cordis_eu_*_publications",
|
||||
{
|
||||
"size": len(batch) * 4, # a DOI can appear in several frameworks
|
||||
"_source": ["doi", "projectID"],
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"term": {"doi": {"value": d, "case_insensitive": True}}}
|
||||
for d in batch
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
for hit in result["hits"]["hits"]:
|
||||
src = hit["_source"]
|
||||
doi = normalize_doi(src.get("doi"))
|
||||
project = src.get("projectID")
|
||||
if doi and project is not None:
|
||||
projects_by_doi[doi].add(str(project))
|
||||
|
||||
counts: dict[str, int] = {}
|
||||
for aid, dois in dois_by_author.items():
|
||||
projects: set[str] = set()
|
||||
for doi in dois:
|
||||
projects |= projects_by_doi.get(doi, set())
|
||||
if projects:
|
||||
counts[aid] = len(projects)
|
||||
return counts
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Orchestration
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def collect_signals(
|
||||
institution_short_id: str,
|
||||
display_names: dict[str, str],
|
||||
dois_by_author: dict[str, set[str]],
|
||||
scored_match_types: tuple[str, ...] = ("institution", "both"),
|
||||
news_require_relevant: bool = True,
|
||||
) -> dict[str, dict[str, int]]:
|
||||
"""All signal joins. Returns per-metric dicts keyed by author_short_id."""
|
||||
with httpx.Client() as client:
|
||||
patents_scored, patents_name_only = patent_counts(
|
||||
client, institution_short_id, scored_match_types
|
||||
)
|
||||
news, ambiguous_skipped = news_mention_counts(
|
||||
client, display_names, require_relevant=news_require_relevant
|
||||
)
|
||||
cordis = cordis_project_counts(client, dois_by_author)
|
||||
print(
|
||||
f"Signals: patents scored for {len(patents_scored)} authors "
|
||||
f"(name-only evidence: {len(patents_name_only)}), "
|
||||
f"news mentions for {len(news)} (ambiguous names skipped: {ambiguous_skipped}), "
|
||||
f"CORDIS projects for {len(cordis)}"
|
||||
)
|
||||
return {
|
||||
"patent_count": patents_scored,
|
||||
"patent_count_name_only": patents_name_only,
|
||||
"news_mentions": news,
|
||||
"cordis_eu_projects": cordis,
|
||||
}
|
||||
@@ -1,656 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
spike_audit.py — M0 de-risking spike for the multiplicator-detection module.
|
||||
|
||||
Extracts the institution's OpenAlex author set (two-group union) and the FULL-authorship
|
||||
work set for those authors, caches both as gzipped JSONL, and prints an audit report that
|
||||
answers the six questions the rest of the pipeline is betting on:
|
||||
|
||||
1. Reproduction — author / work counts vs the known 4,921 / 183,661 for UDE.
|
||||
2. Field coverage — % of authorships with author_position / is_corresponding, and
|
||||
% of institutions with a non-null `type`. Decides whether the
|
||||
mentorship (last-author) and cross-sector signals are computable.
|
||||
3. Scale — authors-per-work histogram and distinct co-author pair counts at
|
||||
caps of 20 / 50 / 100. Picks max_authors_per_work; confirms the
|
||||
"pure Python / polars, no DuckDB" sizing bet.
|
||||
4. Quality — % of authors flagged has_suspicious_publication_years (merged
|
||||
profiles) and the active_years distribution.
|
||||
5. Permissions — can we create / bulk-write / delete on the INSE cluster, and does
|
||||
_delete_by_query 403 there as it does for org_patents?
|
||||
6. Signals — does org_patents carry matched_authors for this institution, and
|
||||
what is the match_type breakdown?
|
||||
|
||||
Unlike the seed (llm_evaluations/.../build_ude_author_work_set.py) this drops inner_hits
|
||||
and pulls every authorship (external co-authors + their institutions) — without that
|
||||
there is no bridging signal.
|
||||
|
||||
Usage:
|
||||
python service/scripts/multipliers/spike_audit.py --institution-id I62318514
|
||||
|
||||
Credentials are read from service/src/main/inse/.env (ELASTICSEARCH_* for the NES/OpenAlex
|
||||
cluster, ELASTICSEARCH_INSE_* for patents/news). Nothing is written to the real cluster
|
||||
unless --probe-writes is passed (it creates and deletes a throwaway index).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import gzip
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import statistics
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterable, Iterator
|
||||
|
||||
import httpx
|
||||
import yaml
|
||||
from dotenv import load_dotenv
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
ENV_PATH = SCRIPT_DIR.parent.parent / "src" / "main" / "inse" / ".env"
|
||||
load_dotenv(dotenv_path=ENV_PATH)
|
||||
|
||||
# --- clusters -------------------------------------------------------------
|
||||
|
||||
NES_URL = (os.environ.get("ELASTICSEARCH_URL") or "").rstrip("/")
|
||||
NES_KEY = os.environ.get("ELASTICSEARCH_API_KEY") or ""
|
||||
INSE_URL = (os.environ.get("ELASTICSEARCH_INSE_URL") or "").rstrip("/")
|
||||
INSE_KEY = os.environ.get("ELASTICSEARCH_INSE_API_KEY") or ""
|
||||
|
||||
# --- extraction knobs (spike-only; the real build reads these from YAML) --
|
||||
|
||||
AFFILIATION_YEAR_GTE = 2025
|
||||
WORK_YEAR_GTE = 1950
|
||||
AUTHOR_PAGE_SIZE = 1000
|
||||
AUTHOR_BATCH_SIZE = 250
|
||||
WORK_PAGE_SIZE = 1000
|
||||
PAIR_CAPS = (20, 50, 100)
|
||||
REQUEST_TIMEOUT = 180.0
|
||||
PROBE_INDEX = "multiplicators_spike_probe"
|
||||
|
||||
|
||||
# ES helpers
|
||||
|
||||
|
||||
def _headers(api_key: str) -> dict[str, str]:
|
||||
return {
|
||||
"Authorization": f"ApiKey {api_key}",
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def es_request(
|
||||
client: httpx.Client,
|
||||
method: str,
|
||||
base_url: str,
|
||||
api_key: str,
|
||||
path: str,
|
||||
body: dict[str, Any] | None = None,
|
||||
) -> httpx.Response:
|
||||
url = f"{base_url}/{path.lstrip('/')}"
|
||||
return client.request(
|
||||
method, url, headers=_headers(api_key), json=body, timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
|
||||
|
||||
def es_search(
|
||||
client: httpx.Client, base_url: str, api_key: str, index: str, body: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
response = es_request(client, "POST", base_url, api_key, f"{index}/_search", body)
|
||||
if not response.is_success:
|
||||
raise RuntimeError(
|
||||
f"ES error {response.status_code} for {index}:\n{response.text[:1000]}"
|
||||
)
|
||||
return response.json()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Institution resolution (parameterised — no hardcoded UDE)
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def resolve_institution(client: httpx.Client, institution_id: str) -> dict[str, Any]:
|
||||
"""Look up ror + display_name for --institution-id from openalex-institutions."""
|
||||
raw = institution_id.strip()
|
||||
short = raw.rsplit("/", 1)[-1]
|
||||
full = f"https://openalex.org/{short}"
|
||||
|
||||
result = es_search(
|
||||
client,
|
||||
NES_URL,
|
||||
NES_KEY,
|
||||
"openalex-institutions",
|
||||
{"size": 1, "query": {"term": {"id": full}}},
|
||||
)
|
||||
hits = result["hits"]["hits"]
|
||||
if not hits:
|
||||
raise SystemExit(f"Institution {full} not found in openalex-institutions.")
|
||||
|
||||
source = hits[0]["_source"]
|
||||
return {
|
||||
"id": full,
|
||||
"short_id": short,
|
||||
"ror": source.get("ror"),
|
||||
"display_name": source.get("display_name"),
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Author queries (two-group union — group 2 recovers empty-last-known authors)
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def recent_affiliation_filter(insts: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
"""Recent affiliation with ANY cohort institution (matched by id, ror as backup)."""
|
||||
ids = [i["id"] for i in insts]
|
||||
shoulds: list[dict[str, Any]] = [{"terms": {"affiliations.institution.id": ids}}]
|
||||
rors = [i["ror"] for i in insts if i.get("ror")]
|
||||
if rors:
|
||||
shoulds.append({"terms": {"affiliations.institution.ror": rors}})
|
||||
return {
|
||||
"nested": {
|
||||
"path": "affiliations",
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"bool": {"should": shoulds, "minimum_should_match": 1}},
|
||||
{"range": {"affiliations.years": {"gte": AFFILIATION_YEAR_GTE}}},
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def last_known_filter(insts: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
"""last_known_institutions membership in the cohort, matched by ID.
|
||||
|
||||
(The seed script matched the display_name string; ID terms are equivalent for a
|
||||
single institution and the only sane option for a multi-institution cohort.)"""
|
||||
return {
|
||||
"nested": {
|
||||
"path": "last_known_institutions",
|
||||
"query": {
|
||||
"terms": {"last_known_institutions.id": [i["id"] for i in insts]}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def last_known_exists_filter() -> dict[str, Any]:
|
||||
return {
|
||||
"nested": {
|
||||
"path": "last_known_institutions",
|
||||
"query": {"exists": {"field": "last_known_institutions.display_name"}},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AUTHOR_SOURCE = [
|
||||
"id",
|
||||
"display_name",
|
||||
"orcid",
|
||||
"works_count",
|
||||
"cited_by_count",
|
||||
"last_known_institutions",
|
||||
"affiliations",
|
||||
]
|
||||
|
||||
|
||||
def author_query(query: dict[str, Any], search_after: Any) -> dict[str, Any]:
|
||||
body = {
|
||||
"size": AUTHOR_PAGE_SIZE,
|
||||
"track_total_hits": True,
|
||||
"_source": AUTHOR_SOURCE,
|
||||
"query": query,
|
||||
"sort": [{"id": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
return body
|
||||
|
||||
|
||||
def collect_authors(
|
||||
client: httpx.Client, insts: list[dict[str, Any]]
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
groups = {
|
||||
"backend_compatible": {
|
||||
"bool": {
|
||||
"filter": [last_known_filter(insts), recent_affiliation_filter(insts)]
|
||||
}
|
||||
},
|
||||
"empty_last_known_recent": {
|
||||
"bool": {
|
||||
"filter": [recent_affiliation_filter(insts)],
|
||||
"must_not": [last_known_exists_filter()],
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
authors: dict[str, dict[str, Any]] = {}
|
||||
for group_name, query in groups.items():
|
||||
search_after = None
|
||||
total = None
|
||||
read = 0
|
||||
while True:
|
||||
result = es_search(
|
||||
client, NES_URL, NES_KEY, "openalex-authors",
|
||||
author_query(query, search_after),
|
||||
)
|
||||
hits = result["hits"]["hits"]
|
||||
if total is None:
|
||||
total = result["hits"]["total"]["value"]
|
||||
print(f" [{group_name}] expected {total}")
|
||||
if not hits:
|
||||
break
|
||||
for hit in hits:
|
||||
src = hit["_source"]
|
||||
aid = src.get("id")
|
||||
if not aid:
|
||||
continue
|
||||
if aid not in authors:
|
||||
authors[aid] = {
|
||||
"id": aid,
|
||||
"display_name": src.get("display_name"),
|
||||
"orcid": src.get("orcid"),
|
||||
"works_count": src.get("works_count"),
|
||||
"cited_by_count": src.get("cited_by_count"),
|
||||
"source_sets": [group_name],
|
||||
}
|
||||
elif group_name not in authors[aid]["source_sets"]:
|
||||
authors[aid]["source_sets"].append(group_name)
|
||||
read += 1
|
||||
search_after = hits[-1]["sort"]
|
||||
print(f" [{group_name}] read {read}/{total}")
|
||||
time.sleep(0.05)
|
||||
return authors
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Work queries — FULL authorships, no inner_hits
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
WORK_SOURCE = [
|
||||
"id",
|
||||
"doi",
|
||||
"publication_year",
|
||||
"type",
|
||||
"cited_by_count",
|
||||
"primary_topic.id",
|
||||
"primary_topic.display_name",
|
||||
"primary_topic.field.id",
|
||||
"primary_topic.field.display_name",
|
||||
"authorships.author.id",
|
||||
"authorships.author.display_name",
|
||||
"authorships.author_position",
|
||||
"authorships.is_corresponding",
|
||||
"authorships.institutions.id",
|
||||
"authorships.institutions.display_name",
|
||||
"authorships.institutions.type",
|
||||
"authorships.institutions.country_code",
|
||||
"authorships.institutions.lineage",
|
||||
]
|
||||
|
||||
|
||||
def works_batch_query(author_ids: list[str], search_after: Any) -> dict[str, Any]:
|
||||
body = {
|
||||
"size": WORK_PAGE_SIZE,
|
||||
"track_total_hits": True,
|
||||
"_source": WORK_SOURCE,
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"range": {"publication_year": {"gte": WORK_YEAR_GTE}}},
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {"terms": {"authorships.author.id": author_ids}},
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
"sort": [{"id": {"order": "asc"}}],
|
||||
}
|
||||
if search_after:
|
||||
body["search_after"] = search_after
|
||||
return body
|
||||
|
||||
|
||||
def collect_works(
|
||||
client: httpx.Client, author_ids: list[str]
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
works: dict[str, dict[str, Any]] = {}
|
||||
total_batches = (len(author_ids) + AUTHOR_BATCH_SIZE - 1) // AUTHOR_BATCH_SIZE
|
||||
for i in range(0, len(author_ids), AUTHOR_BATCH_SIZE):
|
||||
batch = author_ids[i : i + AUTHOR_BATCH_SIZE]
|
||||
batch_no = i // AUTHOR_BATCH_SIZE + 1
|
||||
search_after = None
|
||||
while True:
|
||||
result = es_search(
|
||||
client, NES_URL, NES_KEY, "openalex-works*",
|
||||
works_batch_query(batch, search_after),
|
||||
)
|
||||
hits = result["hits"]["hits"]
|
||||
if not hits:
|
||||
break
|
||||
for hit in hits:
|
||||
src = hit["_source"]
|
||||
wid = src.get("id")
|
||||
if wid and wid not in works:
|
||||
works[wid] = src
|
||||
search_after = hits[-1]["sort"]
|
||||
print(f" work batch {batch_no}/{total_batches}: unique works {len(works)}")
|
||||
time.sleep(0.05)
|
||||
return works
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Cache IO
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def write_jsonl_gz(path: Path, records: Iterable[dict[str, Any]]) -> None:
|
||||
with gzip.open(path, "wt", encoding="utf-8", newline="\n") as f:
|
||||
for record in records:
|
||||
f.write(json.dumps(record, ensure_ascii=True) + "\n")
|
||||
|
||||
|
||||
def read_jsonl_gz(path: Path) -> Iterator[dict[str, Any]]:
|
||||
with gzip.open(path, "rt", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line:
|
||||
yield json.loads(line)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Audit computations
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def _percentile(sorted_vals: list[int], q: float) -> int:
|
||||
if not sorted_vals:
|
||||
return 0
|
||||
idx = min(len(sorted_vals) - 1, int(math.ceil(q * len(sorted_vals)) - 1))
|
||||
return sorted_vals[max(0, idx)]
|
||||
|
||||
|
||||
def audit_field_coverage(works: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
n_authorships = 0
|
||||
with_position = 0
|
||||
with_corresponding = 0
|
||||
n_institutions = 0
|
||||
with_inst_type = 0
|
||||
company_institutions = 0
|
||||
|
||||
for w in works:
|
||||
for a in w.get("authorships", []) or []:
|
||||
n_authorships += 1
|
||||
if a.get("author_position"):
|
||||
with_position += 1
|
||||
if a.get("is_corresponding") is not None:
|
||||
with_corresponding += 1
|
||||
for inst in a.get("institutions", []) or []:
|
||||
n_institutions += 1
|
||||
itype = inst.get("type")
|
||||
if itype:
|
||||
with_inst_type += 1
|
||||
if itype == "company":
|
||||
company_institutions += 1
|
||||
|
||||
def pct(x: int, n: int) -> float:
|
||||
return round(100.0 * x / n, 2) if n else 0.0
|
||||
|
||||
return {
|
||||
"authorships_total": n_authorships,
|
||||
"author_position_pct": pct(with_position, n_authorships),
|
||||
"is_corresponding_pct": pct(with_corresponding, n_authorships),
|
||||
"institutions_total": n_institutions,
|
||||
"institution_type_pct": pct(with_inst_type, n_institutions),
|
||||
"company_institutions": company_institutions,
|
||||
}
|
||||
|
||||
|
||||
def audit_scale(works: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
sizes: list[int] = []
|
||||
pairs_at_cap = {cap: 0 for cap in PAIR_CAPS}
|
||||
for w in works:
|
||||
author_ids = {
|
||||
a["author"]["id"]
|
||||
for a in (w.get("authorships") or [])
|
||||
if a.get("author", {}).get("id")
|
||||
}
|
||||
n = len(author_ids)
|
||||
sizes.append(n)
|
||||
for cap in PAIR_CAPS:
|
||||
if 2 <= n <= cap:
|
||||
pairs_at_cap[cap] += n * (n - 1) // 2
|
||||
sizes_sorted = sorted(sizes)
|
||||
return {
|
||||
"works": len(sizes),
|
||||
"authors_per_work": {
|
||||
"p50": _percentile(sizes_sorted, 0.50),
|
||||
"p90": _percentile(sizes_sorted, 0.90),
|
||||
"p99": _percentile(sizes_sorted, 0.99),
|
||||
"max": sizes_sorted[-1] if sizes_sorted else 0,
|
||||
},
|
||||
"hyperauthorship_works_gt_100": sum(1 for s in sizes if s > 100),
|
||||
"pair_instances_at_cap": pairs_at_cap,
|
||||
}
|
||||
|
||||
|
||||
def audit_career(
|
||||
author_ids: set[str], works: list[dict[str, Any]]
|
||||
) -> dict[str, Any]:
|
||||
"""active_years and suspicious-profile flags for in-set authors (exact history)."""
|
||||
years_by_author: dict[str, set[int]] = collections.defaultdict(set)
|
||||
for w in works:
|
||||
year = w.get("publication_year")
|
||||
if not isinstance(year, int):
|
||||
continue
|
||||
for a in w.get("authorships", []) or []:
|
||||
aid = a.get("author", {}).get("id")
|
||||
if aid in author_ids:
|
||||
years_by_author[aid].add(year)
|
||||
|
||||
active_years_list: list[int] = []
|
||||
suspicious = 0
|
||||
for aid in author_ids:
|
||||
years = years_by_author.get(aid)
|
||||
if not years:
|
||||
continue
|
||||
active_years_list.append(len(years))
|
||||
first_year = min(years)
|
||||
span = max(years) - first_year + 1
|
||||
if first_year < 1970 or span > 60:
|
||||
suspicious += 1
|
||||
|
||||
ay_sorted = sorted(active_years_list)
|
||||
return {
|
||||
"authors_with_works": len(ay_sorted),
|
||||
"suspicious_profile_count": suspicious,
|
||||
"suspicious_profile_pct": (
|
||||
round(100.0 * suspicious / len(ay_sorted), 2) if ay_sorted else 0.0
|
||||
),
|
||||
"active_years": {
|
||||
"p50": _percentile(ay_sorted, 0.50),
|
||||
"p90": _percentile(ay_sorted, 0.90),
|
||||
"max": ay_sorted[-1] if ay_sorted else 0,
|
||||
"mean": round(statistics.fmean(ay_sorted), 2) if ay_sorted else 0.0,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def audit_signals(client: httpx.Client, inst: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Probe org_patents (INSE cluster) for matched_authors + match_type breakdown."""
|
||||
if not INSE_URL or not INSE_KEY:
|
||||
return {"error": "INSE cluster credentials missing"}
|
||||
try:
|
||||
result = es_search(
|
||||
client, INSE_URL, INSE_KEY, "org_patents",
|
||||
{
|
||||
"size": 0,
|
||||
"track_total_hits": True,
|
||||
"query": {"term": {"institution_id": inst["short_id"]}},
|
||||
"aggs": {"by_match_type": {"terms": {"field": "match_type"}}},
|
||||
},
|
||||
)
|
||||
except RuntimeError as exc:
|
||||
return {"error": str(exc)[:300]}
|
||||
buckets = (
|
||||
result.get("aggregations", {}).get("by_match_type", {}).get("buckets", [])
|
||||
)
|
||||
return {
|
||||
"org_patents_for_institution": result["hits"]["total"]["value"],
|
||||
"match_type_breakdown": {b["key"]: b["doc_count"] for b in buckets},
|
||||
}
|
||||
|
||||
|
||||
def audit_permissions(client: httpx.Client, probe_writes: bool) -> dict[str, Any]:
|
||||
"""Test create / bulk / delete-by-query / delete on the INSE cluster."""
|
||||
if not probe_writes:
|
||||
return {"skipped": "pass --probe-writes to test index create/bulk/delete"}
|
||||
if not INSE_URL or not INSE_KEY:
|
||||
return {"error": "INSE cluster credentials missing"}
|
||||
|
||||
out: dict[str, Any] = {}
|
||||
create = es_request(
|
||||
client, "PUT", INSE_URL, INSE_KEY, PROBE_INDEX,
|
||||
{"mappings": {"properties": {"institution_id": {"type": "keyword"}}}},
|
||||
)
|
||||
out["create_index"] = create.status_code
|
||||
if create.is_success:
|
||||
bulk_body = (
|
||||
json.dumps({"index": {"_index": PROBE_INDEX, "_id": "probe_1"}})
|
||||
+ "\n"
|
||||
+ json.dumps({"institution_id": "PROBE"})
|
||||
+ "\n"
|
||||
)
|
||||
bulk = client.post(
|
||||
f"{INSE_URL}/_bulk",
|
||||
headers={**_headers(INSE_KEY), "Content-Type": "application/x-ndjson"},
|
||||
content=bulk_body,
|
||||
timeout=REQUEST_TIMEOUT,
|
||||
)
|
||||
out["bulk_index"] = bulk.status_code
|
||||
client.post(f"{INSE_URL}/{PROBE_INDEX}/_refresh", headers=_headers(INSE_KEY))
|
||||
dbq = es_request(
|
||||
client, "POST", INSE_URL, INSE_KEY, f"{PROBE_INDEX}/_delete_by_query",
|
||||
{"query": {"term": {"institution_id": "PROBE"}}},
|
||||
)
|
||||
out["delete_by_query"] = dbq.status_code # expect 403 if it mirrors org_patents
|
||||
drop = es_request(client, "DELETE", INSE_URL, INSE_KEY, PROBE_INDEX)
|
||||
out["delete_index"] = drop.status_code
|
||||
return out
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Main
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--institution-id", required=True)
|
||||
parser.add_argument(
|
||||
"--config", default=str(SCRIPT_DIR / "multipliers.yaml"),
|
||||
help="YAML config; its cohorts.<ID>.institution_ids extends the author set "
|
||||
"beyond the primary institution (e.g. the university hospital).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cache-dir", default=str(SCRIPT_DIR / "cache"),
|
||||
help="Where to read/write the extracted author/work JSONL.gz",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip-extract", action="store_true",
|
||||
help="Reuse cached JSONL.gz instead of hitting ES for author/work extraction.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--probe-writes", action="store_true",
|
||||
help="Create+bulk+delete a throwaway index on INSE to test write permissions.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not NES_URL or not NES_KEY:
|
||||
raise SystemExit(f"Missing NES credentials. Checked {ENV_PATH}")
|
||||
|
||||
cache_dir = Path(args.cache_dir)
|
||||
cache_dir.mkdir(parents=True, exist_ok=True)
|
||||
short = args.institution_id.strip().rsplit("/", 1)[-1]
|
||||
authors_path = cache_dir / f"authors_{short}.jsonl.gz"
|
||||
works_path = cache_dir / f"works_{short}.jsonl.gz"
|
||||
|
||||
cohort_ids = [short]
|
||||
config_path = Path(args.config)
|
||||
if config_path.exists():
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
cfg = yaml.safe_load(f) or {}
|
||||
cohort_cfg = (cfg.get("cohorts") or {}).get(short) or {}
|
||||
if cohort_cfg.get("institution_ids"):
|
||||
cohort_ids = [str(i) for i in cohort_cfg["institution_ids"]]
|
||||
|
||||
with httpx.Client() as client:
|
||||
insts = [resolve_institution(client, i) for i in cohort_ids]
|
||||
inst = insts[0] # primary
|
||||
print(f"Cohort ({len(insts)} institutions):")
|
||||
for i in insts:
|
||||
print(f" {i['short_id']:<14} {i['display_name']}")
|
||||
|
||||
if args.skip_extract and authors_path.exists() and works_path.exists():
|
||||
print("Reusing cached extract.")
|
||||
authors = {a["id"]: a for a in read_jsonl_gz(authors_path)}
|
||||
works = list(read_jsonl_gz(works_path))
|
||||
else:
|
||||
print("\nExtracting authors...")
|
||||
authors = collect_authors(client, insts)
|
||||
write_jsonl_gz(authors_path, authors.values())
|
||||
print(f"Authors: {len(authors)} -> {authors_path}")
|
||||
|
||||
print("\nExtracting works (full authorships)...")
|
||||
author_ids = sorted(authors.keys())
|
||||
works_map = collect_works(client, author_ids)
|
||||
works = list(works_map.values())
|
||||
write_jsonl_gz(works_path, works)
|
||||
print(f"Works: {len(works)} -> {works_path}")
|
||||
|
||||
author_id_set = set(authors.keys())
|
||||
|
||||
print("\nComputing audit...")
|
||||
report = {
|
||||
"institution": inst,
|
||||
"cohort": [
|
||||
{"id": i["short_id"], "display_name": i["display_name"]} for i in insts
|
||||
],
|
||||
"reproduction": {
|
||||
"author_count": len(authors),
|
||||
"work_count": len(works),
|
||||
"group_breakdown": dict(
|
||||
collections.Counter(
|
||||
tuple(sorted(a["source_sets"])) and "+".join(sorted(a["source_sets"]))
|
||||
for a in authors.values()
|
||||
)
|
||||
),
|
||||
},
|
||||
"field_coverage": audit_field_coverage(works),
|
||||
"scale": audit_scale(works),
|
||||
"career_quality": audit_career(author_id_set, works),
|
||||
"signals": audit_signals(client, inst),
|
||||
"permissions": audit_permissions(client, args.probe_writes),
|
||||
}
|
||||
|
||||
report_path = cache_dir / f"spike_report_{short}.json"
|
||||
with open(report_path, "w", encoding="utf-8", newline="\n") as f:
|
||||
json.dump(report, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print("\n=== SPIKE AUDIT REPORT ===")
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
print(f"\nWritten: {report_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,130 +0,0 @@
|
||||
"""Tests for graph construction (pair generation, weights, caps, node aggregates)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from graph import build_graph, focal_subgraph, short_id
|
||||
|
||||
|
||||
def make_work(wid, year, authors, field_id=None):
|
||||
"""authors: list of (author_id, institutions[(id,type)], position)."""
|
||||
return {
|
||||
"id": f"https://openalex.org/{wid}",
|
||||
"publication_year": year,
|
||||
"primary_topic": (
|
||||
{"field": {"id": f"https://openalex.org/fields/{field_id}"}}
|
||||
if field_id
|
||||
else None
|
||||
),
|
||||
"authorships": [
|
||||
{
|
||||
"author": {"id": f"https://openalex.org/{aid}", "display_name": aid},
|
||||
"author_position": pos,
|
||||
"institutions": [
|
||||
{"id": f"https://openalex.org/{iid}", "type": itype}
|
||||
for iid, itype in insts
|
||||
],
|
||||
}
|
||||
for aid, insts, pos in authors
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
UDE = [("I1", "education")]
|
||||
COMPANY = [("I9", "company")]
|
||||
|
||||
|
||||
def test_short_id():
|
||||
assert short_id("https://openalex.org/A5023888391") == "A5023888391"
|
||||
assert short_id("A5023888391") == "A5023888391"
|
||||
assert short_id(None) is None
|
||||
|
||||
|
||||
def test_edge_weight_decay_and_team_size():
|
||||
works = [
|
||||
make_work("W1", 2026, [("A1", UDE, "first"), ("A2", UDE, "last")]),
|
||||
make_work("W2", 2025, [("A1", UDE, "first"), ("A2", UDE, "last")]),
|
||||
]
|
||||
g = build_graph(works, {"A1", "A2"}, decay=0.8)
|
||||
assert g.ref_year == 2026
|
||||
e = g.edges[("A1", "A2")]
|
||||
# W1: 0.8^0 / 1 = 1.0 ; W2: 0.8^1 / 1 = 0.8
|
||||
assert e.weight == pytest.approx(1.8)
|
||||
assert e.n_works == 2
|
||||
assert e.first_joint_year == 2025
|
||||
assert e.last_joint_year == 2026
|
||||
|
||||
|
||||
def test_team_size_divides_weight():
|
||||
works = [
|
||||
make_work(
|
||||
"W1", 2026,
|
||||
[("A1", UDE, "first"), ("A2", UDE, "middle"), ("A3", UDE, "last")],
|
||||
)
|
||||
]
|
||||
g = build_graph(works, {"A1", "A2", "A3"})
|
||||
# n_authors=3 -> each pair gets 1/(3-1) = 0.5
|
||||
assert g.edges[("A1", "A2")].weight == pytest.approx(0.5)
|
||||
assert len(g.edges) == 3
|
||||
|
||||
|
||||
def test_hyperauthorship_cap_excludes_pairs_but_keeps_years():
|
||||
big = make_work(
|
||||
"W1", 2020, [(f"A{i}", UDE, "middle") for i in range(1, 61)]
|
||||
)
|
||||
small = make_work("W2", 2021, [("A1", UDE, "first"), ("A2", UDE, "last")])
|
||||
g = build_graph([big, small], {"A1", "A2"}, max_authors_per_work=50)
|
||||
assert g.n_works_capped == 1
|
||||
assert g.n_works_used == 1
|
||||
assert set(g.edges) == {("A1", "A2")}
|
||||
# capped work still contributes publication years
|
||||
assert 2020 in g.nodes["A1"].publication_years
|
||||
assert 2021 in g.nodes["A1"].publication_years
|
||||
|
||||
|
||||
def test_cross_institution_weight():
|
||||
works = [
|
||||
make_work("W1", 2026, [("A1", UDE, "first"), ("A2", COMPANY, "last")]),
|
||||
make_work("W2", 2026, [("A1", UDE, "first"), ("A3", UDE, "last")]),
|
||||
]
|
||||
g = build_graph(works, {"A1", "A2", "A3"})
|
||||
assert g.edges[("A1", "A2")].cross_inst_weight == pytest.approx(1.0)
|
||||
assert g.edges[("A1", "A3")].cross_inst_weight == pytest.approx(0.0)
|
||||
|
||||
|
||||
def test_company_share_and_fields():
|
||||
works = [
|
||||
make_work("W1", 2026, [("A1", UDE, "first"), ("A2", COMPANY, "last")], "F11"),
|
||||
make_work("W2", 2026, [("A1", UDE, "first"), ("A3", UDE, "last")], "F22"),
|
||||
]
|
||||
g = build_graph(works, {"A1"})
|
||||
n = g.nodes["A1"]
|
||||
assert n.n_company_works == 1 and n.n_typed_works == 2
|
||||
assert n.field_counts == {"F11": 1, "F22": 1}
|
||||
|
||||
|
||||
def test_focal_subgraph_excludes_externals():
|
||||
works = [
|
||||
make_work("W1", 2026, [("A1", UDE, "first"), ("EXT", COMPANY, "last")]),
|
||||
make_work("W2", 2026, [("A1", UDE, "first"), ("A2", UDE, "last")]),
|
||||
]
|
||||
g = build_graph(works, {"A1", "A2"})
|
||||
internal = focal_subgraph(g)
|
||||
assert "EXT" not in internal
|
||||
assert set(internal["A1"].keys()) == {"A2"}
|
||||
|
||||
|
||||
def test_last_author_junior_first_recorded():
|
||||
works = [
|
||||
make_work("W1", 2026, [("JUNIOR", UDE, "first"), ("PROF", UDE, "last")]),
|
||||
]
|
||||
g = build_graph(works, {"JUNIOR", "PROF"})
|
||||
assert g.nodes["PROF"].last_author_junior_first == [("JUNIOR", 2026)]
|
||||
assert g.nodes["JUNIOR"].last_author_junior_first == []
|
||||
|
||||
|
||||
def test_duplicate_authorships_deduped():
|
||||
w = make_work("W1", 2026, [("A1", UDE, "first"), ("A1", UDE, "last"), ("A2", UDE, "middle")])
|
||||
g = build_graph([w], {"A1", "A2"})
|
||||
# A1 duplicated -> counts once; n_authors=2 -> weight divisor 1
|
||||
assert g.edges[("A1", "A2")].weight == pytest.approx(1.0)
|
||||
@@ -1,231 +0,0 @@
|
||||
"""Tests for metrics: betweenness vs networkx oracle, constraint on a star,
|
||||
active_years_at robustness (the planted-1893-outlier regression guard), mentor logic."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from graph import build_graph
|
||||
from metrics import (
|
||||
active_years_at,
|
||||
betweenness_centrality,
|
||||
burt_constraint,
|
||||
compute_all_metrics,
|
||||
field_entropy,
|
||||
is_suspicious_profile,
|
||||
mentor_metrics,
|
||||
)
|
||||
from test_graph import UDE, make_work
|
||||
|
||||
networkx = pytest.importorskip("networkx")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# active_years_at — THE regression guard for the whole design premise
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_active_years_at_unmoved_by_planted_1893_outlier():
|
||||
"""A single misattributed 1893 work must shift active_years_at by exactly 1,
|
||||
unlike first_pub_year-based career age, which it would shift by ~120 years."""
|
||||
clean = set(range(2010, 2026)) # 16 active years
|
||||
poisoned = clean | {1893} # merged-profile artifact
|
||||
|
||||
assert active_years_at(clean, 2025) == 16
|
||||
assert active_years_at(poisoned, 2025) == 17 # +1, not +120
|
||||
# seniority classification at the time of an early collaboration is unaffected
|
||||
assert active_years_at(clean, 2013) == 4 # still "Early" in 2013
|
||||
assert active_years_at(poisoned, 2013) == 5 # off by exactly one year
|
||||
|
||||
# the poisoned profile IS flagged for evidence confidence
|
||||
assert not is_suspicious_profile(clean)
|
||||
assert is_suspicious_profile(poisoned)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# betweenness — barbell fixture + networkx oracle
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def _nx_graph(adj):
|
||||
g = networkx.Graph()
|
||||
for a, neigh in adj.items():
|
||||
g.add_node(a)
|
||||
for b, w in neigh.items():
|
||||
g.add_edge(a, b, weight=w, distance=1.0 / w)
|
||||
return g
|
||||
|
||||
|
||||
def test_betweenness_barbell_bridge_dominates():
|
||||
"""Two triangles joined by one bridge node: the bridge has max betweenness."""
|
||||
adj = {}
|
||||
|
||||
def add(a, b, w=1.0):
|
||||
adj.setdefault(a, {})[b] = w
|
||||
adj.setdefault(b, {})[a] = w
|
||||
|
||||
for x, y in [("A", "B"), ("B", "C"), ("A", "C")]:
|
||||
add(x, y)
|
||||
for x, y in [("D", "E"), ("E", "F"), ("D", "F")]:
|
||||
add(x, y)
|
||||
add("C", "M")
|
||||
add("M", "D")
|
||||
|
||||
bc = betweenness_centrality(adj)
|
||||
assert bc["M"] == max(bc.values())
|
||||
assert bc["A"] == pytest.approx(0.0)
|
||||
|
||||
oracle = networkx.betweenness_centrality(
|
||||
_nx_graph(adj), weight="distance", normalized=True
|
||||
)
|
||||
for node, value in bc.items():
|
||||
assert value == pytest.approx(oracle[node], abs=1e-9), node
|
||||
|
||||
|
||||
def test_betweenness_weighted_paths_vs_oracle():
|
||||
"""Weighted graph where the shortest path is NOT the fewest-hops path."""
|
||||
adj = {}
|
||||
|
||||
def add(a, b, w):
|
||||
adj.setdefault(a, {})[b] = w
|
||||
adj.setdefault(b, {})[a] = w
|
||||
|
||||
# strong two-hop route A-X-B (distance 0.2+0.2) beats direct weak A-B (distance 2)
|
||||
add("A", "B", 0.5)
|
||||
add("A", "X", 5.0)
|
||||
add("X", "B", 5.0)
|
||||
add("B", "C", 1.0)
|
||||
|
||||
bc = betweenness_centrality(adj)
|
||||
oracle = networkx.betweenness_centrality(
|
||||
_nx_graph(adj), weight="distance", normalized=True
|
||||
)
|
||||
for node, value in bc.items():
|
||||
assert value == pytest.approx(oracle[node], abs=1e-9), node
|
||||
assert bc["X"] > 0.0 # X sits on the A->B shortest path
|
||||
|
||||
|
||||
def test_betweenness_random_graph_vs_oracle():
|
||||
"""Randomized (but seeded) graph, full oracle comparison."""
|
||||
rng = networkx.gnm_random_graph(24, 60, seed=7)
|
||||
adj = {}
|
||||
for a, b in rng.edges():
|
||||
w = ((a * 31 + b * 17) % 9 + 1) / 3.0 # deterministic pseudo-weights
|
||||
adj.setdefault(str(a), {})[str(b)] = w
|
||||
adj.setdefault(str(b), {})[str(a)] = w
|
||||
for n in rng.nodes():
|
||||
adj.setdefault(str(n), {})
|
||||
|
||||
bc = betweenness_centrality(adj)
|
||||
oracle = networkx.betweenness_centrality(
|
||||
_nx_graph(adj), weight="distance", normalized=True
|
||||
)
|
||||
for node, value in bc.items():
|
||||
assert value == pytest.approx(oracle[node], abs=1e-7), node
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Burt constraint — star fixture
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_constraint_star_center_is_unconstrained():
|
||||
"""Star: the hub bridges structural holes (low constraint); each spoke is
|
||||
fully dependent on the hub (constraint 1.0). Clique members sit in between."""
|
||||
star = {}
|
||||
for spoke in ["S1", "S2", "S3", "S4"]:
|
||||
star.setdefault("HUB", {})[spoke] = 1.0
|
||||
star[spoke] = {"HUB": 1.0}
|
||||
c = burt_constraint(star)
|
||||
assert c["HUB"] == pytest.approx(0.25) # sum of (1/4)^2 * 4
|
||||
for spoke in ["S1", "S2", "S3", "S4"]:
|
||||
assert c[spoke] == pytest.approx(1.0)
|
||||
|
||||
triangle = {
|
||||
"A": {"B": 1.0, "C": 1.0},
|
||||
"B": {"A": 1.0, "C": 1.0},
|
||||
"C": {"A": 1.0, "B": 1.0},
|
||||
}
|
||||
c3 = burt_constraint(triangle)
|
||||
# closed triad: everyone highly constrained, more than the star hub
|
||||
assert c3["A"] > c["HUB"]
|
||||
oracle = networkx.constraint(_nx_graph(triangle), weight="weight")
|
||||
assert c3["A"] == pytest.approx(oracle["A"], abs=1e-9)
|
||||
|
||||
|
||||
def test_field_entropy():
|
||||
assert field_entropy({}) == 0.0
|
||||
assert field_entropy({"F1": 10}) == 0.0
|
||||
assert field_entropy({"F1": 5, "F2": 5}) == pytest.approx(1.0)
|
||||
assert field_entropy({"F1": 1, "F2": 1, "F3": 1, "F4": 1}) == pytest.approx(2.0)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Mentor metrics
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def _career(aid, years, wid_prefix):
|
||||
"""Solo-ish works giving `aid` a publication history (paired with a throwaway
|
||||
co-author so the works survive the n_authors >= 2 filter)."""
|
||||
return [
|
||||
make_work(f"{wid_prefix}{y}", y, [(aid, UDE, "first"), (f"X_{aid}_{y}", [], "last")])
|
||||
for y in years
|
||||
]
|
||||
|
||||
|
||||
def test_mentor_seniority_gap_and_progression():
|
||||
works = []
|
||||
# PROF: established since 2000 (>=10 active years by 2015)
|
||||
works += _career("PROF", range(2000, 2026), "P")
|
||||
# JUNIOR: first-ever activity 2015 (active_years_at(2015)=1), then progresses
|
||||
works += [
|
||||
make_work("J1", 2015, [("JUNIOR", UDE, "first"), ("PROF", UDE, "last")]),
|
||||
]
|
||||
works += _career("JUNIOR", range(2016, 2022), "J") # 6 more years -> progressed
|
||||
# PEER: senior colleague, first joint work 2020 when both are senior
|
||||
works += _career("PEER", range(2000, 2026), "Q")
|
||||
works += [make_work("JP", 2020, [("PEER", UDE, "first"), ("PROF", UDE, "last")])]
|
||||
|
||||
g = build_graph(works, {"PROF", "JUNIOR", "PEER"})
|
||||
mm = mentor_metrics(g, "PROF")
|
||||
|
||||
assert mm.juniors_mentored == 1
|
||||
assert mm.junior_ids == ["JUNIOR"]
|
||||
assert mm.junior_progression_rate == pytest.approx(1.0)
|
||||
# PROF was last author on J1 with a junior first author
|
||||
assert mm.last_author_with_junior_first == 1
|
||||
# the senior PEER never counts
|
||||
assert "PEER" not in mm.junior_ids
|
||||
|
||||
|
||||
def test_mentor_excludes_external_coauthors():
|
||||
"""External co-authors have truncated year-sets and must never count as juniors."""
|
||||
works = _career("PROF", range(2000, 2026), "P")
|
||||
works += [make_work("E1", 2020, [("EXT", [], "first"), ("PROF", UDE, "last")])]
|
||||
g = build_graph(works, {"PROF"}) # EXT not focal
|
||||
mm = mentor_metrics(g, "PROF")
|
||||
assert mm.juniors_mentored == 0
|
||||
assert mm.last_author_with_junior_first == 0
|
||||
|
||||
|
||||
def test_mentor_requires_focal_seniority_at_first_joint_year():
|
||||
"""Two juniors co-publishing: neither mentors the other."""
|
||||
works = [
|
||||
make_work("W1", 2020, [("J1", UDE, "first"), ("J2", UDE, "last")]),
|
||||
make_work("W2", 2021, [("J1", UDE, "first"), ("J2", UDE, "last")]),
|
||||
]
|
||||
g = build_graph(works, {"J1", "J2"})
|
||||
assert mentor_metrics(g, "J2").juniors_mentored == 0
|
||||
|
||||
|
||||
def test_compute_all_metrics_shapes():
|
||||
works = _career("PROF", range(2000, 2026), "P")
|
||||
works += [make_work("J1", 2015, [("JUNIOR", UDE, "first"), ("PROF", UDE, "last")])]
|
||||
g = build_graph(works, {"PROF", "JUNIOR"})
|
||||
rows = compute_all_metrics(g)
|
||||
assert set(rows) == {"PROF", "JUNIOR"}
|
||||
prof = rows["PROF"]
|
||||
assert prof["juniors_mentored"] == 1
|
||||
assert prof["active_years"] == 26
|
||||
assert 0.0 <= prof["industry_coauthor_share"] <= 1.0
|
||||
assert prof["suspicious_profile"] is False
|
||||
@@ -1,120 +0,0 @@
|
||||
"""Property-style tests for scoring: percentile bounds, tie handling, bucket isolation,
|
||||
weight redistribution for missing metrics, tagging rules."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from scoring import career_bucket, percentile_ranks, score_rows
|
||||
|
||||
CONFIG = {
|
||||
"_config_hash": "testhash",
|
||||
"career": {"buckets": [4, 9, 14], "bucket_names": ["Early", "Emerging", "Established", "Senior"]},
|
||||
"weights": {
|
||||
"bridger": {"betweenness": 0.5, "field_entropy": 0.5},
|
||||
"mentor": {"juniors_mentored": 1.0},
|
||||
},
|
||||
"tags": {"threshold": 0.85, "min_active_years": 2},
|
||||
}
|
||||
|
||||
|
||||
def row(aid, active_years, betweenness=0.0, entropy=0.0, juniors=0):
|
||||
return {
|
||||
"author_id": aid,
|
||||
"active_years": active_years,
|
||||
"betweenness": betweenness,
|
||||
"field_entropy": entropy,
|
||||
"juniors_mentored": juniors,
|
||||
"junior_ids": [],
|
||||
}
|
||||
|
||||
|
||||
def test_career_bucket_thresholds_match_backend():
|
||||
names = ["Early", "Emerging", "Established", "Senior"]
|
||||
assert career_bucket(1, [4, 9, 14], names) == "Early"
|
||||
assert career_bucket(4, [4, 9, 14], names) == "Early"
|
||||
assert career_bucket(5, [4, 9, 14], names) == "Emerging"
|
||||
assert career_bucket(9, [4, 9, 14], names) == "Emerging"
|
||||
assert career_bucket(10, [4, 9, 14], names) == "Established"
|
||||
assert career_bucket(14, [4, 9, 14], names) == "Established"
|
||||
assert career_bucket(15, [4, 9, 14], names) == "Senior"
|
||||
|
||||
|
||||
def test_percentiles_in_zero_one_and_ties_share_mean_rank():
|
||||
p = percentile_ranks({"a": 1.0, "b": 2.0, "c": 3.0, "d": 4.0})
|
||||
assert all(0.0 < v <= 1.0 for v in p.values())
|
||||
assert p["d"] == pytest.approx(1.0)
|
||||
assert p["a"] == pytest.approx(0.25)
|
||||
|
||||
# a metric that is 0 for most people must not hand out high percentiles
|
||||
p = percentile_ranks({"a": 0, "b": 0, "c": 0, "d": 5})
|
||||
assert p["a"] == pytest.approx(0.5) # mean rank of the 3-way tie: (1+2+3)/3 / 4
|
||||
assert p["d"] == pytest.approx(1.0)
|
||||
# None values are excluded entirely
|
||||
p = percentile_ranks({"a": None, "b": 1.0})
|
||||
assert "a" not in p and p["b"] == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_percentiles_computed_within_buckets_not_across():
|
||||
rows = {
|
||||
# Early bucket: modest raw values
|
||||
"e1": row("e1", 2, betweenness=0.1, entropy=0.5),
|
||||
"e2": row("e2", 3, betweenness=0.0, entropy=0.0),
|
||||
# Senior bucket: huge raw values
|
||||
"s1": row("s1", 20, betweenness=0.9, entropy=3.0),
|
||||
"s2": row("s2", 25, betweenness=0.8, entropy=2.0),
|
||||
}
|
||||
scored = {r["author_id"]: r for r in score_rows(rows, CONFIG)}
|
||||
# e1 tops the EARLY bucket despite raw values far below the seniors
|
||||
assert scored["e1"]["percentiles"]["betweenness"] == pytest.approx(1.0)
|
||||
assert scored["s1"]["percentiles"]["betweenness"] == pytest.approx(1.0)
|
||||
assert scored["e1"]["career_bucket"] == "Early"
|
||||
assert scored["s1"]["career_bucket"] == "Senior"
|
||||
|
||||
|
||||
def test_monotonicity_more_bridging_never_lowers_score():
|
||||
base = {
|
||||
"a": row("a", 3, betweenness=0.1, entropy=1.0),
|
||||
"b": row("b", 3, betweenness=0.2, entropy=1.0),
|
||||
"c": row("c", 3, betweenness=0.3, entropy=1.0),
|
||||
}
|
||||
improved = {
|
||||
"a": row("a", 3, betweenness=0.25, entropy=1.0), # a gains betweenness
|
||||
"b": row("b", 3, betweenness=0.2, entropy=1.0),
|
||||
"c": row("c", 3, betweenness=0.3, entropy=1.0),
|
||||
}
|
||||
s_base = {r["author_id"]: r for r in score_rows(base, CONFIG)}
|
||||
s_improved = {r["author_id"]: r for r in score_rows(improved, CONFIG)}
|
||||
assert (
|
||||
s_improved["a"]["sub_scores"]["bridger"]
|
||||
>= s_base["a"]["sub_scores"]["bridger"]
|
||||
)
|
||||
|
||||
|
||||
def test_missing_metric_weight_redistributed():
|
||||
rows = {
|
||||
"a": {**row("a", 3, entropy=2.0), "betweenness": None},
|
||||
"b": {**row("b", 3, entropy=1.0), "betweenness": None},
|
||||
}
|
||||
scored = {r["author_id"]: r for r in score_rows(rows, CONFIG)}
|
||||
# bridger falls back to entropy alone; the top entropy holder gets 1.0
|
||||
assert scored["a"]["sub_scores"]["bridger"] == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_tags_fire_above_threshold_and_respect_min_active_years():
|
||||
rows = {
|
||||
# 8-person Early bucket: m ranks 7/8 = 0.875 >= 0.85 threshold
|
||||
**{f"x{i}": row(f"x{i}", 3, juniors=0) for i in range(6)},
|
||||
"m": row("m", 3, juniors=7),
|
||||
"newbie": {**row("newbie", 1, juniors=9), "active_years": 1},
|
||||
}
|
||||
scored = {r["author_id"]: r for r in score_rows(rows, CONFIG)}
|
||||
assert "mentor" in scored["m"]["tags"]
|
||||
assert scored["newbie"]["tags"] == [] # min_active_years=2 gate
|
||||
|
||||
|
||||
def test_output_carries_raw_percentile_subscore_and_hash():
|
||||
scored = score_rows({"a": row("a", 3, betweenness=0.5)}, CONFIG)[0]
|
||||
assert scored["betweenness"] == 0.5 # raw
|
||||
assert "betweenness" in scored["percentiles"] # percentile
|
||||
assert "bridger" in scored["sub_scores"] # sub-score
|
||||
assert scored["config_hash"] == "testhash"
|
||||
@@ -1,35 +0,0 @@
|
||||
"""Tests for the pure parts of the signal joins: name/DOI normalization and
|
||||
the ambiguity rule for news matching."""
|
||||
from __future__ import annotations
|
||||
|
||||
from signals import normalize_doi, normalize_name
|
||||
|
||||
|
||||
def test_normalize_name_diacritics_case_whitespace():
|
||||
assert normalize_name("René Müller") == "rene muller"
|
||||
assert normalize_name("CHRISTOPH GILLE") == "christoph gille" # news is often ALL-CAPS
|
||||
assert normalize_name(" Anna-Lena Giesecke ") == "anna-lena giesecke"
|
||||
assert normalize_name("Barbara Saccà") == normalize_name("Barbara Sacca")
|
||||
assert normalize_name("Bülent Eken") == "bulent eken"
|
||||
|
||||
|
||||
def test_normalize_doi_prefixes_and_case():
|
||||
assert normalize_doi("https://doi.org/10.1371/journal.pone.0018216") == \
|
||||
"10.1371/journal.pone.0018216"
|
||||
assert normalize_doi("DOI:10.1016/J.CELL.2020.01.001") == "10.1016/j.cell.2020.01.001"
|
||||
assert normalize_doi("doi.org/10.1/x") == "10.1/x"
|
||||
assert normalize_doi("10.1/x") == "10.1/x"
|
||||
assert normalize_doi("") is None
|
||||
assert normalize_doi(None) is None
|
||||
|
||||
|
||||
def test_ambiguous_name_rule():
|
||||
"""Two cohort authors normalizing to the same name -> both excluded from news."""
|
||||
from collections import defaultdict
|
||||
names = {"A1": "Wei Zhang", "A2": "Wei ZHANG", "A3": "Unique Person"}
|
||||
by_norm = defaultdict(list)
|
||||
for aid, n in names.items():
|
||||
by_norm[normalize_name(n)].append(aid)
|
||||
ambiguous = {k for k, v in by_norm.items() if len(v) > 1}
|
||||
assert normalize_name("Wei Zhang") in ambiguous
|
||||
assert normalize_name("Unique Person") not in ambiguous
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
validate_sample.py — M1 exit check against the 60-person hand-labeled sample.
|
||||
|
||||
analysis/career_stage/career_stage_sample.csv holds 60 UDE researchers with
|
||||
manually verified status (31 Professor / 29 Researcher incl. doctoral). The
|
||||
mentor sub-score is a proxy for supervision with no ground truth in OpenAlex,
|
||||
so the cheapest sanity check is: mentor scores must concentrate on the
|
||||
professors. If they don't, the proxy is wrong and M2 waits (plan §5, M1 exit).
|
||||
|
||||
Usage:
|
||||
python validate_sample.py --institution-id I62318514
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
import gzip
|
||||
import json
|
||||
import statistics
|
||||
from pathlib import Path
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
REPO_ROOT = SCRIPT_DIR.parent.parent.parent
|
||||
SAMPLE_CSV = REPO_ROOT / "analysis" / "career_stage" / "career_stage_sample.csv"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--institution-id", required=True)
|
||||
parser.add_argument("--cache-dir", default=str(SCRIPT_DIR / "cache"))
|
||||
args = parser.parse_args()
|
||||
|
||||
short = args.institution_id.strip().rsplit("/", 1)[-1]
|
||||
scores_path = Path(args.cache_dir) / f"scores_{short}.jsonl.gz"
|
||||
if not scores_path.exists():
|
||||
raise SystemExit(f"Run build.py first — missing {scores_path}")
|
||||
|
||||
scores: dict[str, dict] = {}
|
||||
with gzip.open(scores_path, "rt", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
row = json.loads(line)
|
||||
scores[row["author_id"]] = row
|
||||
|
||||
sample: list[dict] = []
|
||||
with open(SAMPLE_CSV, newline="", encoding="utf-8-sig") as f:
|
||||
for rec in csv.DictReader(f):
|
||||
sample.append(rec)
|
||||
|
||||
by_status: dict[str, list[dict]] = {}
|
||||
missing: list[str] = []
|
||||
for rec in sample:
|
||||
aid = rec["openalex_author_id"].strip()
|
||||
row = scores.get(aid)
|
||||
if row is None:
|
||||
missing.append(f"{rec['name']} ({aid})")
|
||||
continue
|
||||
by_status.setdefault(rec["known_status"], []).append(
|
||||
{"name": rec["name"], "discipline": rec["discipline_group"], **row}
|
||||
)
|
||||
|
||||
print(f"Sample: {len(sample)} people, matched in scores: "
|
||||
f"{sum(len(v) for v in by_status.values())}, missing: {len(missing)}")
|
||||
for m in missing:
|
||||
print(f" MISSING: {m}")
|
||||
|
||||
report: dict = {"missing": missing, "by_status": {}}
|
||||
for sub in ("mentor", "bridger", "amplifier"):
|
||||
print(f"\n=== {sub} sub-score by known status ===")
|
||||
for status, rows in sorted(by_status.items()):
|
||||
vals = [r["sub_scores"][sub] for r in rows]
|
||||
entry = {
|
||||
"n": len(vals),
|
||||
"median": round(statistics.median(vals), 3),
|
||||
"mean": round(statistics.fmean(vals), 3),
|
||||
"min": round(min(vals), 3),
|
||||
"max": round(max(vals), 3),
|
||||
}
|
||||
report["by_status"].setdefault(status, {})[sub] = entry
|
||||
print(f" {status:<12} n={entry['n']:>2} median={entry['median']:.3f} "
|
||||
f"mean={entry['mean']:.3f} range=[{entry['min']:.3f}, {entry['max']:.3f}]")
|
||||
|
||||
# headline check: professors' median mentor score > researchers'
|
||||
prof = report["by_status"].get("Professor", {}).get("mentor", {})
|
||||
res = report["by_status"].get("Researcher", {}).get("mentor", {})
|
||||
if prof and res:
|
||||
ok = prof["median"] > res["median"]
|
||||
print(f"\nM1 exit check — professors' median mentor score "
|
||||
f"({prof['median']}) > researchers' ({res['median']}): "
|
||||
f"{'PASS' if ok else 'FAIL'}")
|
||||
report["m1_exit_mentor_check"] = "PASS" if ok else "FAIL"
|
||||
|
||||
# per-person detail for eyeballing
|
||||
print("\n=== per-person (sorted by mentor score) ===")
|
||||
everyone = [r for rows in by_status.values() for r in rows]
|
||||
for r in sorted(everyone, key=lambda x: x["sub_scores"]["mentor"], reverse=True):
|
||||
status = next(s for s, rows in by_status.items() if r in rows)
|
||||
print(f" {r['sub_scores']['mentor']:.3f} {status:<11} {r['career_bucket']:<12}"
|
||||
f" juniors={r['juniors_mentored']:>3} laj={r['last_author_with_junior_first']:>3}"
|
||||
f" {r['name']} ({r['discipline']})")
|
||||
|
||||
out = Path(args.cache_dir) / f"validation_{short}.json"
|
||||
with open(out, "w", encoding="utf-8", newline="\n") as f:
|
||||
json.dump(report, f, ensure_ascii=False, indent=2)
|
||||
print(f"\nReport -> {out}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,556 +0,0 @@
|
||||
# Founding-Potential Prediction — Experiments
|
||||
|
||||
This folder contains a self-contained, reproducible pipeline that answers two
|
||||
research questions using the Dimensions researcher-metadata datasets in
|
||||
[`../dimensions_data`](../dimensions_data) and [`../evaluation`](../evaluation):
|
||||
|
||||
- **RQ1** — *Can we classify founders vs. non-founders from full-career
|
||||
researcher metadata?*
|
||||
- **RQ2** — *Can we predict, from a truncated ("half") profile taken N years
|
||||
before founding, whether/when a researcher will go on to found a company —
|
||||
and does that signal hold up at a longer, unseen horizon and under a
|
||||
time-to-event (survival) framing?*
|
||||
|
||||
Both baselines ("primitive" models) and modern gradient-boosting / ensemble /
|
||||
deep-learning models are trained side by side so the added value of more
|
||||
sophisticated modeling can be judged directly.
|
||||
|
||||
> **⚠️ 2026-08 redesign — read before using any RQ1/RQ2 numbers below.**
|
||||
> A production probe showed the original RQ1 classifier is an
|
||||
> *inverse-productivity score* (1 publication → P(founder)=0.996, 800 →
|
||||
> 0.0002) and the RQ2 `p_within_3y/5y` outputs are degenerate (≡1.0 for every
|
||||
> author). Root cause: the "pre-founding fix" truncates founders' totals at
|
||||
> their founding year while non-founders keep full-career totals, so
|
||||
> observation-window length itself encodes the label; the 0.918→0.976 ROC-AUC
|
||||
> "improvement" from that fix is class-separability leakage, not noise
|
||||
> removal. The corrected **symmetric landmark design** lives in
|
||||
> `src/symmetric.py` (+ `src/yearly_counts.py`, `src/career_curves.py`), is
|
||||
> trained by `run_rq1_symmetric.py` / `run_rq2_symmetric.py`, and reports
|
||||
> honest numbers (RQ1 holdout ROC-AUC 0.874 / PR-AUC 0.726 after population +
|
||||
> plausibility filtering; temporal-split PR-AUC ≈0.73; all RQ2 horizons
|
||||
> discriminating at ROC-AUC 0.86–0.89). The rebuild also surfaced and filtered
|
||||
> two further class-asymmetric dataset artifacts: a sampling-frame clash on
|
||||
> thin profiles (founders from company databases vs non-founders from
|
||||
> institutional researcher lists) and name-collision aggregate profiles
|
||||
> concentrated in the non-founder class — see
|
||||
> `production/classifier_symmetric/README.md`. The sections below describe the
|
||||
> original (superseded) pipeline and are kept for the paper-trail.
|
||||
|
||||
## Environment
|
||||
|
||||
All work runs in a dedicated conda environment named **`potential`**.
|
||||
|
||||
```bash
|
||||
# Recreate from scratch
|
||||
conda create -n potential -c conda-forge python=3.11 pandas numpy scikit-learn \
|
||||
matplotlib seaborn joblib tqdm -y
|
||||
conda activate potential
|
||||
pip install xgboost lightgbm catboost shap lifelines imbalanced-learn tabulate
|
||||
conda install -n potential -c conda-forge pytorch -y # installed via conda, not pip
|
||||
|
||||
# Or reproduce the exact resolved environment:
|
||||
conda env create -f environment.yml
|
||||
```
|
||||
|
||||
> **Why PyTorch via conda and not pip?** Pip's PyTorch wheel bundles its own
|
||||
> OpenMP runtime, which crashes (`OMP: Error #15 ... libomp.dylib already
|
||||
> initialized`) when mixed with the conda-forge OpenMP runtime used by numpy /
|
||||
> scikit-learn / LightGBM on macOS. Installing `pytorch` from `conda-forge`
|
||||
> shares a single OpenMP runtime with everything else, and it works fine.
|
||||
|
||||
Run everything with:
|
||||
|
||||
```bash
|
||||
cd experiments
|
||||
conda run -n potential python run_rq1.py
|
||||
conda run -n potential python run_rq2.py
|
||||
```
|
||||
|
||||
> **Known benign warning**: `run_rq1.py`'s SHAP step can print a
|
||||
> `mutex lock failed` abort trace *after* the pipeline has already finished
|
||||
> and all result files have been written — it happens during Python
|
||||
> interpreter shutdown (a threading/OpenMP teardown race between
|
||||
> SHAP/LightGBM/CatBoost), not during actual computation. Check for the
|
||||
> `All RQ1 results written to ...` line and the contents of `results/rq1/` to
|
||||
> confirm success; ignore the trailing stack trace if that line is present.
|
||||
|
||||
## Repository layout
|
||||
|
||||
```
|
||||
experiments/
|
||||
environment.yml # exported conda environment (reproducibility)
|
||||
src/
|
||||
config.py # paths, constants, leakage-safe feature allow/deny lists
|
||||
data.py # leakage-safe loaders + feature-matrix builders for RQ1/RQ2
|
||||
splits.py # stratified holdout + leave-one-institution-out split helper
|
||||
outliers.py # two-stage IsolationForest outlier detection
|
||||
models.py # baseline + advanced/SOTA model factories, stacking ensemble
|
||||
# (scale-sensitive models wrapped in StandardScaler pipelines)
|
||||
tuning.py # RandomizedSearchCV hyperparameter search spaces + tune_model()
|
||||
nn.py # PyTorch MLP baseline (sklearn-style wrapper)
|
||||
sequence_data.py # founder-only pre-founding activity sequence dataset builder
|
||||
sequence_models.py # PyTorch LSTM/Transformer sequence regressors (sklearn-style)
|
||||
evaluate.py # metrics, comparison tables, plots, McNemar test, CV+CI,
|
||||
# bootstrap CI, calibration curves, stratified-by-group metrics
|
||||
explain.py # permutation importance + SHAP
|
||||
survival.py # CoxPH time-to-event modeling for RQ2
|
||||
run_rq1.py # RQ1 orchestration script
|
||||
run_rq2.py # RQ2 orchestration script
|
||||
run_rq1_robustness.py # ablation, CV+CI, tuning, calibration, bootstrap, area-stratified
|
||||
run_sequence_founders.py # founder-only LSTM/Transformer founding-age prediction pipeline
|
||||
results/
|
||||
rq1/ # RQ1 tables, plots, trained model, explainability output
|
||||
rq2/ # RQ2 tables, trained model, survival summary
|
||||
rq1_robustness/ # ablation/CV/tuning/calibration/bootstrap/area-stratified output
|
||||
sequence_founders/ # sequence-model comparison tables + plots
|
||||
```
|
||||
|
||||
`run_rq1.py` / `run_rq2.py` add `src/` to `sys.path` at runtime rather than
|
||||
relying on an installed package — simplest option for a self-contained
|
||||
experiments folder that isn't meant to be pip-installed elsewhere.
|
||||
|
||||
## Data leakage findings (important)
|
||||
|
||||
While auditing `evaluation/datasets_complete` (full-career features, 161 raw
|
||||
columns) before modeling, two families of columns were found to be
|
||||
**identically zero for every non-founder row**, i.e. broken/undefined outside
|
||||
the founder class:
|
||||
|
||||
1. `hist_{pub,pat,grant}_FN{+,-}{1..20}` and the no-suffix `hist_{pub,pat,grant}_FN`
|
||||
columns (activity counts indexed relative to the *founding* year).
|
||||
2. `{publications,patents,grants,activities}_{before,after}_founding`.
|
||||
|
||||
A classifier trained on the raw column set would trivially "solve" RQ1 by
|
||||
detecting this artifact (non-founders always have 0 there) rather than
|
||||
learning genuine founder traits. Both families are explicitly excluded via
|
||||
`config.RQ1_DROP_COLUMNS` (a deny-list built and empirically verified with
|
||||
`.describe()` on the raw CSVs), leaving 24 legitimate full-career numeric
|
||||
aggregates (h-index, publications, patents, grants, g-index,
|
||||
`industry_collab_papers`, etc.) plus 3 research-area categoricals and
|
||||
`institution`.
|
||||
|
||||
The 3 research-area columns (`publication_research_area`,
|
||||
`patent_research_area`, `grant_research_area`) originally carried 100+ specific
|
||||
Dimensions codes each (e.g. `"3205 Medical Biochemistry and Metabolomics"`).
|
||||
One-hot encoding them directly produced ~250 mostly-empty sparse columns, so
|
||||
`data.build_rq1_matrix` first collapses each to its 2-digit broad parent code
|
||||
(e.g. `"32"`) before one-hot encoding, reducing RQ1's feature matrix from 248
|
||||
columns down to **99** while keeping discipline-level signal.
|
||||
|
||||
The original repository's non-founder downsampling used `df[:n]` — the first
|
||||
N rows, not a random sample. This experiments pipeline instead either (a)
|
||||
trains on the full class-imbalanced data with `class_weight='balanced'` /
|
||||
`scale_pos_weight` / `auto_class_weights='Balanced'` (RQ1), or (b) uses a
|
||||
documented, fixed-`random_state` 70/30 `train_test_split` to reserve a
|
||||
non-founder holdout pool that is never touched during RQ2 training
|
||||
(`data._nonfounder_pool_split`).
|
||||
|
||||
## RQ1 — Founder vs. non-founder classification
|
||||
|
||||
**Data**: `evaluation/datasets_complete`, 8 institutions pooled, restricted to
|
||||
*pre-founding* activity only (see "Data leakage findings" above), with
|
||||
multivariate outlier rows removed via a two-stage sanity-ceiling +
|
||||
IsolationForest filter (`src/outliers.py`, 165/16,494 rows flagged). After
|
||||
leakage-column removal: **16,494 rows, 99 features, 36.8% founders**.
|
||||
|
||||
**Split**: single stratified 80/20 holdout (`random_state=42`).
|
||||
|
||||
**Models**: `dummy_most_frequent`, `logistic_regression`, `gaussian_nb`, `knn`,
|
||||
`decision_tree` (baselines); `random_forest`, `svm_rbf`, `xgboost`, `lightgbm`,
|
||||
`catboost`, a `stacking_ensemble` (RF + XGBoost + LightGBM → logistic
|
||||
meta-learner), and a PyTorch `torch_mlp` (advanced / SOTA-ish set). The
|
||||
scale-sensitive models (`logistic_regression`, `gaussian_nb`, `knn`, `svm_rbf`)
|
||||
are wrapped in a `StandardScaler` pipeline — raw features span very different
|
||||
ranges (e.g. citation counts vs. binary flags), and without scaling these
|
||||
models were being penalized relative to the (scale-invariant) tree ensembles.
|
||||
Tree-based models are intentionally left unscaled.
|
||||
|
||||
### Held-out test results (`results/rq1/rq1_model_comparison.csv`)
|
||||
|
||||
| model | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| lightgbm | 0.930 | 0.913 | 0.894 | 0.903 | **0.976** | **0.969** | 0.848 |
|
||||
| stacking_ensemble | 0.927 | 0.897 | 0.906 | 0.901 | 0.975 | 0.968 | 0.843 |
|
||||
| xgboost | 0.927 | 0.907 | 0.893 | 0.900 | 0.974 | 0.967 | 0.843 |
|
||||
| catboost | 0.922 | 0.903 | 0.885 | 0.894 | 0.972 | 0.963 | 0.833 |
|
||||
| torch_mlp | 0.920 | 0.898 | 0.881 | 0.890 | 0.962 | 0.955 | 0.827 |
|
||||
| random_forest | 0.896 | 0.873 | 0.839 | 0.856 | 0.952 | 0.935 | 0.774 |
|
||||
| logistic_regression | 0.882 | 0.824 | 0.864 | 0.843 | 0.943 | 0.928 | 0.749 |
|
||||
| svm_rbf | 0.875 | 0.845 | 0.810 | 0.827 | 0.937 | 0.914 | 0.730 |
|
||||
| decision_tree | 0.838 | 0.738 | 0.867 | 0.797 | 0.921 | 0.883 | 0.669 |
|
||||
| knn | 0.818 | 0.816 | 0.654 | 0.726 | 0.881 | 0.821 | 0.601 |
|
||||
| gaussian_nb | 0.724 | 0.806 | 0.331 | 0.469 | 0.816 | 0.721 | 0.383 |
|
||||
| dummy_most_frequent | 0.632 | 0.000 | 0.000 | 0.000 | 0.500 | 0.368 | 0.000 |
|
||||
|
||||
Best baseline: `logistic_regression` (PR-AUC 0.928). Best overall: `lightgbm`
|
||||
(PR-AUC 0.969). A McNemar test between the two
|
||||
(`results/rq1/mcnemar_baseline_vs_best.csv`) gives χ²=83.8, p≈5.4e-20 — the
|
||||
gain from advanced/ensembled models over the best linear baseline is
|
||||
statistically significant, not noise. (These held-out numbers, and the ones
|
||||
below, are corroborated by the independent 5-fold CV and bootstrap-CI results
|
||||
in "Robustness & foolproofing checks" above — e.g. lightgbm's 5-fold PR-AUC
|
||||
of 0.970 [0.967, 0.973] matches this single-split PR-AUC of 0.969 closely.)
|
||||
|
||||
### Cross-institution generalization (leave-one-institution-out)
|
||||
|
||||
Using the same 99-feature matrix but rebuilt **without** the institution
|
||||
one-hot columns (`include_institution=False`), each of the 3 top tree-based
|
||||
models is trained on 7 institutions and tested on the 8th, in turn
|
||||
(`results/rq1/rq1_leave_one_institution_out.csv`). Mean across institutions:
|
||||
|
||||
| model | roc_auc | pr_auc | mcc |
|
||||
|---|---|---|---|
|
||||
| xgboost | 0.953 | 0.922 | 0.779 |
|
||||
| lightgbm | 0.952 | 0.922 | 0.782 |
|
||||
| random_forest | 0.940 | 0.900 | 0.738 |
|
||||
|
||||
Generalization to an unseen institution is nearly as strong as in-distribution
|
||||
performance (compare to the ~0.97 ROC-AUC / ~0.97 PR-AUC of the pooled
|
||||
holdout above) — the learned founder signal is not merely an artifact of
|
||||
institution-specific quirks. `muenchen` and `toronto` are consistently the
|
||||
weakest held-out institutions (ROC-AUC ~0.85), and `telaviv` the strongest
|
||||
(ROC-AUC ~0.99) — see the per-institution breakdown in the CSV for the full
|
||||
picture; this is likely driven by per-institution sample size and founder
|
||||
rate rather than anything model-specific.
|
||||
|
||||
### Explainability (`results/rq1/permutation_importance.csv`, `plots/shap_summary.png`)
|
||||
|
||||
Top permutation-importance features on the best tree model (LightGBM), by
|
||||
mean drop in PR-AUC when permuted:
|
||||
|
||||
1. `publications` (0.444)
|
||||
2. `pub_citation_sum` (0.064)
|
||||
3. `last_patent_year` (0.061)
|
||||
4. `i10-index` (0.053)
|
||||
5. `pub_citation_mean` (0.042)
|
||||
6. `g-index` (0.036)
|
||||
7. `activities_total` (0.032)
|
||||
8. `pat_citation_mean` (0.024)
|
||||
9. `grants` (0.015)
|
||||
10. `first_publication_year` (0.013)
|
||||
|
||||
With the pre-founding fix applied, `publications` (pre-founding publication
|
||||
count) is now overwhelmingly the dominant signal, followed by citation-impact
|
||||
measures and patenting recency. This is a notably cleaner, more concentrated
|
||||
importance profile than before the fix (previously the top feature accounted
|
||||
for ~0.055 importance with a long, flat tail) — consistent with the ablation
|
||||
finding that the pre-founding restriction sharpens rather than removes signal.
|
||||
|
||||
|
||||
|
||||
## RQ2 — Time-to-founding prediction from a truncated profile
|
||||
|
||||
**Data**: curated 13-column half-profile founder datasets at offsets 1/2/3
|
||||
years before founding (`evaluation/datasets_halfprofiles_offset{1,2,3}`),
|
||||
paired with non-founders from `datasets_complete` using the *same* curated
|
||||
columns (legitimate/non-degenerate for non-founders too). Non-founders per
|
||||
institution are split 70/30 once (fixed seed) into a training pool (offsets
|
||||
1-3) and a holdout pool reserved exclusively for horizon-validation, so no
|
||||
individual is ever seen in both training and generalization testing.
|
||||
|
||||
### Per-offset comparison (`results/rq2/rq2_offset_comparison.csv`)
|
||||
|
||||
PR-AUC by model × offset (years before founding):
|
||||
|
||||
| model | offset=1 | offset=2 | offset=3 |
|
||||
|---|---|---|---|
|
||||
| lightgbm | 0.906 | 0.908 | **0.915** |
|
||||
| xgboost | 0.908 | **0.910** | 0.914 |
|
||||
| random_forest | 0.905 | 0.906 | 0.910 |
|
||||
| decision_tree | 0.843 | 0.844 | 0.860 |
|
||||
| logistic_regression | 0.829 | 0.830 | 0.837 |
|
||||
| dummy_most_frequent | 0.434 | 0.434 | 0.434 |
|
||||
|
||||
Predictive power increases (modestly) the closer the profile snapshot is to
|
||||
the actual founding event, as expected, and gradient-boosted trees clearly
|
||||
beat the linear/dummy baselines at every horizon.
|
||||
|
||||
### Pooled multi-horizon model + extrapolation validation
|
||||
|
||||
A single LightGBM model is trained on offsets 1-3 pooled (with `offset` as an
|
||||
explicit feature) and evaluated on:
|
||||
- its own held-out test split (in-distribution): **ROC-AUC 0.954, PR-AUC 0.947**
|
||||
- `datasets_halfprofiles_validation_offset3` — an **in-range** horizon never
|
||||
used for training these specific rows: **ROC-AUC 0.949, PR-AUC 0.945**
|
||||
- `datasets_halfprofiles_validation_offset5` — an **extrapolation** horizon
|
||||
(offset=5 was never seen during training at all): **ROC-AUC 0.942, PR-AUC 0.941**
|
||||
|
||||
(`results/rq2/rq2_horizon_validation.csv`.) The degradation from in-range to
|
||||
extrapolation is small (ROC-AUC 0.949 → 0.942), but note the caveat: tree
|
||||
ensembles cannot truly extrapolate a numeric feature (`offset`) beyond the
|
||||
range seen in training, so this result should be read as "still works
|
||||
reasonably at a nearby unseen horizon," not proof of extrapolation to
|
||||
arbitrarily distant horizons.
|
||||
|
||||
### Survival analysis (CoxPH) as a complementary framing
|
||||
|
||||
Fixed-horizon classification requires picking specific offsets in advance.
|
||||
As a principled alternative, `src/survival.py` fits a Cox proportional-hazards
|
||||
model where the event is "founded a company" and the duration is years from
|
||||
first publication to founding (or to last observed publication, censored, for
|
||||
non-founders). Covariates are full-career aggregates (a simplification since
|
||||
they are not truly time-varying — see the docstring in `survival.py` for this
|
||||
known limitation).
|
||||
|
||||
- **Concordance index (held-out): 0.715** — the model ranks who-founds-sooner
|
||||
meaningfully better than chance, but well below the classifiers above.
|
||||
- **P(founds within 5y) AUC on eligible held-out rows: 0.656** (landmark
|
||||
analysis avoiding immortal-time bias), versus the pooled classifier's
|
||||
extrapolation ROC-AUC of 0.942 at the same horizon.
|
||||
|
||||
The purpose-built fixed-horizon classifier substantially outperforms CoxPH
|
||||
here, most likely because: (a) the classifier gets to use the curated,
|
||||
horizon-specific half-profile features directly, while CoxPH's covariates are
|
||||
full-career aggregates rather than genuinely time-varying; and (b) CoxPH's
|
||||
proportional-hazards assumption is a real constraint the classifiers don't
|
||||
need to satisfy. The full `cph.print_summary()` (coefficients, hazard ratios,
|
||||
p-values) is captured in the run log and shows `pub_citation_sum`,
|
||||
`patents`/`pat_citation_sum`, and `affiliations` as the strongest positive
|
||||
hazard-ratio covariates, consistent with the RQ1 permutation-importance
|
||||
findings.
|
||||
|
||||
## Robustness & foolproofing checks (RQ1)
|
||||
|
||||
Beyond a single train/test split, `run_rq1_robustness.py` runs a battery of
|
||||
checks aimed at making the RQ1 result trustworthy rather than a lucky split,
|
||||
and at answering two specific questions: *does the pre-founding-leakage fix
|
||||
actually help or hurt?* and *should the model be split up by research area?*
|
||||
All numbers below come from actual executed runs; results are saved under
|
||||
`results/rq1_robustness/`.
|
||||
|
||||
### Ablation: does the pre-founding fix help or hurt?
|
||||
|
||||
An earlier audit found that the raw full-career activity totals technically
|
||||
include activity *after* founding (reverse causation — the model could partly
|
||||
"see the future"). The fix restricts these aggregates to pre-founding
|
||||
activity only. Comparing the two directly (`ablation_prefounding_fix.csv`):
|
||||
|
||||
| variant | n | roc_auc | pr_auc |
|
||||
|---|---|---|---|
|
||||
| fix ON (pre-founding only) | 16,494 | **0.976** | **0.969** |
|
||||
| fix OFF (raw lifetime totals) | 16,466 | 0.918 | 0.886 |
|
||||
|
||||
~~The fix *improves* performance, which is counter to the naive expectation
|
||||
that "removing a leak should hurt." The interpretation: the raw lifetime
|
||||
totals aren't a source of illegitimately-helpful signal here so much as
|
||||
*noise* — removing that dilution helps.~~
|
||||
|
||||
**Superseded (2026-08):** that interpretation was wrong. The +6-point jump is
|
||||
the tell, not noise removal: truncating one class's observation window and not
|
||||
the other's makes "small totals" a class marker, which a production probe
|
||||
confirmed (P(founder) strictly decreasing in publications, at every threshold).
|
||||
The honest comparison requires truncating *both* classes at a matched index
|
||||
date — see the redesign note at the top and `run_rq1_symmetric.py`, which
|
||||
lands at ROC-AUC ≈0.91 with a domain-plausible (hump-shaped) relationship
|
||||
between output and founding probability.
|
||||
|
||||
### 5-fold cross-validation with 95% confidence intervals
|
||||
|
||||
(`cv_summary_mean.csv`; per-fold detail in `cv_<model>.csv`.)
|
||||
|
||||
| model | pr_auc (95% CI) | roc_auc (95% CI) |
|
||||
|---|---|---|
|
||||
| lightgbm | 0.970 [0.967, 0.973] | 0.978 [0.976, 0.980] |
|
||||
| xgboost | 0.968 [0.965, 0.972] | 0.977 [0.974, 0.980] |
|
||||
| random_forest | 0.936 [0.930, 0.942] | 0.953 [0.947, 0.958] |
|
||||
| logistic_regression | 0.923 [0.917, 0.928] | 0.942 [0.936, 0.947] |
|
||||
| dummy_most_frequent | 0.368 [0.368, 0.369] | 0.500 |
|
||||
|
||||
Tight confidence intervals across folds confirm the held-out results above
|
||||
aren't an artifact of one lucky split.
|
||||
|
||||
### Hyperparameter tuning (RandomizedSearchCV)
|
||||
|
||||
(`tuning_comparison.csv`, `tuning_best_params.json`.) 20-iteration randomized
|
||||
search, 3-fold CV, optimizing PR-AUC:
|
||||
|
||||
| model | pr_auc default → tuned | roc_auc default → tuned |
|
||||
|---|---|---|
|
||||
| random_forest | 0.935 → **0.953** | 0.952 → 0.965 |
|
||||
| xgboost | 0.967 → **0.971** | 0.974 → 0.978 |
|
||||
| lightgbm | 0.969 → **0.971** | 0.976 → 0.978 |
|
||||
|
||||
Tuning gives a modest but consistent lift for every model, largest for
|
||||
random_forest. The tuned LightGBM is used as the reference model for the
|
||||
calibration and bootstrap analyses below.
|
||||
|
||||
### Calibration (`plots/calibration.png`)
|
||||
|
||||
Reliability diagrams (predicted probability vs. observed founder rate, in
|
||||
quantile bins) for logistic regression and both default/tuned LightGBM all
|
||||
track close to the diagonal — the model's probability outputs are
|
||||
meaningfully interpretable as probabilities, not just a ranking score.
|
||||
LightGBM is slightly better calibrated than logistic regression in the
|
||||
low-probability region.
|
||||
|
||||
### Bootstrap confidence intervals (tuned LightGBM, 1000 resamples)
|
||||
|
||||
(`bootstrap_ci.csv`.) Percentile bootstrap on the held-out test set:
|
||||
|
||||
| metric | estimate | 95% CI |
|
||||
|---|---|---|
|
||||
| accuracy | 0.937 | [0.929, 0.945] |
|
||||
| precision | 0.926 | [0.911, 0.941] |
|
||||
| recall | 0.900 | [0.883, 0.916] |
|
||||
| f1 | 0.913 | [0.901, 0.924] |
|
||||
| roc_auc | 0.978 | [0.973, 0.982] |
|
||||
| pr_auc | 0.971 | [0.965, 0.976] |
|
||||
| mcc | 0.863 | [0.845, 0.881] |
|
||||
|
||||
### Does research area affect the results? (stratified evaluation + per-area specialists)
|
||||
|
||||
This was a specific concern raised: founders in different research areas
|
||||
might look systematically different, and pooling everyone together could hide
|
||||
or distort area-specific effects. Two checks were run.
|
||||
|
||||
**1. Stratified evaluation** — the pooled tuned model's held-out predictions
|
||||
were broken out by broad (2-digit) research area (`area_stratified_pooled_model.csv`,
|
||||
22 groups, N from 7 to 1,166). The model performs well **uniformly** across
|
||||
areas — no area catastrophically fails. Largest groups: area "32" (N=1,166)
|
||||
roc_auc=0.967/pr_auc=0.936; area "31" (N=377) roc_auc=0.973/pr_auc=0.936; area
|
||||
"40" (N=244) roc_auc=0.962/pr_auc=0.964. Smaller areas (N<100) show more
|
||||
variance (expected from smaller sample sizes) but generally still PR-AUC
|
||||
0.91-1.0.
|
||||
|
||||
**2. Per-area specialist vs. pooled model** — for each of the 7 largest
|
||||
research areas (N≥500), a dedicated model trained *only* on that area's data
|
||||
was compared against the pooled model evaluated on the same area's subset
|
||||
(`per_area_specialist_vs_pooled.csv`):
|
||||
|
||||
| area | N (specialist train) | specialist pr_auc | pooled pr_auc |
|
||||
|---|---|---|---|
|
||||
| 32 | 4,721 | 0.929 | **0.936** |
|
||||
| 40 | 1,847 | 0.933 | **0.964** |
|
||||
| 51 | 1,012 | 0.848 | **0.941** |
|
||||
| 34 | 462 | 0.909 | **0.965** |
|
||||
|
||||
**The pooled model beats the dedicated specialist on every single area
|
||||
tested.** Splitting the model by research area hurts performance — the loss
|
||||
of training data per specialist (hundreds to a few thousand rows, vs. ~13k
|
||||
for the pooled model) outweighs any benefit from area-specific
|
||||
specialization. **Conclusion: keep research area as a pooled feature, don't
|
||||
split the model by area.**
|
||||
|
||||
## Sequence modeling — can a transformer predict *when* someone will found a company?
|
||||
|
||||
The activity-count aggregates used in RQ1/RQ2 discard *order* — e.g. two
|
||||
founders with the same total pre-founding publication count look identical
|
||||
even if one had a burst of activity right before founding and the other had
|
||||
a burst 15 years earlier. To test whether sequence order carries additional
|
||||
signal, `run_sequence_founders.py` builds true year-by-year sequences and
|
||||
compares an LSTM and a Transformer against simpler baselines on the task of
|
||||
predicting **founding_age** (years from first publication to founding) from
|
||||
the preceding 20-year window of publication/patent/grant activity.
|
||||
|
||||
### Data construction and a data-quality fix
|
||||
|
||||
`founding_age = founded_on − first_publication_year` computed naively across
|
||||
all 6,158 founders gave an absurd range (**−2,022 to +2,022**), revealing
|
||||
that a meaningful subset of founders have sentinel/placeholder year values
|
||||
(not just non-founders, as previously found). Fix: restrict to founders where
|
||||
*both* `founded_on` and `first_publication_year` fall in a plausible
|
||||
`[1950, 2024]` range (drops 1,741/6,158 implausible founders → 4,417 remain),
|
||||
then further restrict to `founding_age` in `[1, 20]` since the 20-year
|
||||
lookback window structurally can't resolve longer careers — this is a
|
||||
deliberate, documented scoping decision, not a hidden limitation. **2,298
|
||||
founders** remain for the sequence task (`src/sequence_data.py`).
|
||||
|
||||
### Results (`results/sequence_founders/`)
|
||||
|
||||
| model | mae | rmse | r2 |
|
||||
|---|---|---|---|
|
||||
| transformer | **0.180** | 0.269 | 0.998 |
|
||||
| lstm | 0.208 | **0.258** | 0.998 |
|
||||
| naive_first_activity (heuristic) | 0.554 | 1.885 | 0.888 |
|
||||
| aggregate_rf (summary stats, no order) | 2.571 | 3.424 | 0.630 |
|
||||
|
||||
(`naive_first_activity` is a zero-parameter heuristic: founding_age is
|
||||
inferred purely from how many leading zero-activity years precede the first
|
||||
nonzero year. `aggregate_rf` is a random forest on 9 summary features — total,
|
||||
nonzero-year count, and last-3-years sum per channel — deliberately
|
||||
*discarding* order, to isolate the value of order/position information.)
|
||||
|
||||
**Honest interpretation**: the task has strong structural determinism — even
|
||||
the naive heuristic gets R²=0.888 just by counting leading zero years, so
|
||||
this isn't a "hard AI problem" in the sense of needing deep learning to make
|
||||
it tractable at all. The meaningful findings are: (1) the LSTM/Transformer
|
||||
are far more **robust** than the brittle heuristic (~3x lower MAE, 0.55 → 0.18–0.21
|
||||
— the heuristic breaks badly on a single spurious early activity blip, the
|
||||
sequence models don't), and (2) sequence models vastly outperform the
|
||||
non-positional aggregate-stats baseline (R² 0.63 → 0.998), proving that
|
||||
**order/position information, not just totals, is what the extra modeling
|
||||
power is capturing.** This is reported as a robustness/precision gain over
|
||||
simpler methods, not an overclaimed "novel predictive capability."
|
||||
|
||||
### Why there's no founder-vs-non-founder sequence classifier
|
||||
|
||||
The natural next step — building comparable sequences for non-founders too,
|
||||
to train a founder-vs-non-founder *sequence* classifier (a more direct test
|
||||
of the "sequential transformer" idea) — was investigated and found **not
|
||||
feasible with the data available in this workspace**, for two independent,
|
||||
confirmed reasons:
|
||||
|
||||
1. Non-founders' `hist_{pub,pat,grant}_FN[+-]N` columns in
|
||||
`evaluation/datasets_complete` are computed by
|
||||
`extraction/non_founders_scripts.ipynb`'s `generate_history(...,
|
||||
nonstartup=True)`, which hardcodes `founded_year = 0` for non-founders —
|
||||
these columns are anchored at literal calendar year 0 and are **entirely
|
||||
zero** (verified via `.sum()==0` / `.max()==0` across every non-founder row).
|
||||
They were never usable for this and are correctly excluded from
|
||||
`config.RQ1_NUMERIC_COLUMNS` already (no leakage risk in the existing RQ1
|
||||
model).
|
||||
2. As a fallback, the raw `dimensions_data/{institution}_papers.csv` files
|
||||
were checked directly for a possible reconstruction path. These files
|
||||
turn out to contain **only founders' publication records** — verified on
|
||||
Stanford by matching tracked researcher names against the raw file's
|
||||
`author_people` column: **85.8%** of founders (1,580/1,842) match, versus
|
||||
**0%** of non-founders (0/2,482). No raw non-founder paper/patent pull
|
||||
files exist anywhere in the workspace (only pre-aggregated
|
||||
`*_nonfounders_features_dataset.csv` summaries) — the underlying raw data
|
||||
would need to be re-collected from the Dimensions API, which is out of
|
||||
scope here.
|
||||
|
||||
Given this, the founder-only founding-age sequence model above is the
|
||||
deliverable for the "sequential transformer" investigation. Building a
|
||||
founder-vs-non-founder sequence classifier would require re-querying the
|
||||
Dimensions API for non-founders' raw, per-year publication/patent history.
|
||||
|
||||
(Side note for any future data-collection work: `dimensions_data/*_papers.csv`
|
||||
already has a pre-matched flat `author_people` name column + numeric `year`
|
||||
column, exploded to one row per paper per tracked founder — reconstructing a
|
||||
person's per-year totals is a simple `groupby(["author_people","year"]).size()`
|
||||
away, no need to fuzzy-match the nested `authors` JSON-like list yourself.
|
||||
Loading just `usecols=["author_people","year"]` is fast — about 10s even for
|
||||
a 4.4GB/600K-row file — and reproduces `datasets_complete`'s `publications`
|
||||
totals almost exactly, 98.1% exact match, correlation 0.99999997, for the
|
||||
founders whose names do match.)
|
||||
|
||||
## Answering the research questions
|
||||
|
||||
- **RQ1**: Yes. LightGBM classifies founders vs. non-founders with ROC-AUC
|
||||
0.976 / PR-AUC 0.969 on held-out data, a statistically significant
|
||||
improvement (McNemar p≈5.4e-20) over the best simple baseline (logistic
|
||||
regression, ROC-AUC 0.943), and generalizes well to institutions unseen
|
||||
during training (mean ROC-AUC 0.95 under leave-one-institution-out).
|
||||
- **RQ2**: Yes, with caveats. Gradient-boosted models predict founding within
|
||||
a 1-3 year horizon from truncated profiles with ROC-AUC ≈ 0.91-0.92, and a
|
||||
pooled multi-horizon model still achieves ROC-AUC 0.94 at a 5-year horizon
|
||||
it never trained on directly (small degradation vs. 0.95 in-distribution).
|
||||
A CoxPH survival model provides a complementary, assumption-explicit
|
||||
time-to-event view but underperforms the direct classifier (concordance
|
||||
0.715, 5-year AUC 0.656), which is expected given it uses less
|
||||
horizon-specific information.
|
||||
- **Is this robust, or a lucky split?** The RQ1 result holds up under 5-fold
|
||||
CV (tight 95% CIs), bootstrap resampling, hyperparameter tuning, and
|
||||
calibration checks — see "Robustness & foolproofing checks" above. The
|
||||
pre-founding leakage fix specifically *improves* performance rather than
|
||||
degrading it (0.976 vs 0.918 ROC-AUC), and the model performs uniformly
|
||||
well across all 22 research-area groups, with a pooled model beating
|
||||
every dedicated per-area specialist tested.
|
||||
- **Does sequence order (not just totals) matter?** Yes. LSTM/Transformer
|
||||
models predicting founding_age from ordered 20-year activity sequences
|
||||
achieve R²=0.998, versus R²=0.63 for an equivalent non-positional
|
||||
aggregate-stats model — see "Sequence modeling" above. A comparable
|
||||
founder-vs-non-founder sequence classifier was investigated but found
|
||||
infeasible with data available in this workspace (non-founders lack any
|
||||
usable raw or pre-aggregated sequence data).
|
||||
@@ -1,404 +0,0 @@
|
||||
{
|
||||
"meta":{"test_sets":[],"test_metrics":[],"learn_metrics":[{"best_value":"Min","name":"Logloss"}],"launch_mode":"Train","parameters":"","iteration_count":400,"learn_sets":["learn"],"name":"experiment"},
|
||||
"iterations":[
|
||||
{"learn":[0.6752574527],"iteration":0,"passed_time":0.001151431995,"remaining_time":0.4594213658},
|
||||
{"learn":[0.6590158329],"iteration":1,"passed_time":0.002307072378,"remaining_time":0.4591074033},
|
||||
{"learn":[0.6439053461],"iteration":2,"passed_time":0.003364919794,"remaining_time":0.4452910527},
|
||||
{"learn":[0.6300318652],"iteration":3,"passed_time":0.00447839295,"remaining_time":0.443360902},
|
||||
{"learn":[0.6176080869],"iteration":4,"passed_time":0.005583615996,"remaining_time":0.4411056637},
|
||||
{"learn":[0.6072057723],"iteration":5,"passed_time":0.006660005325,"remaining_time":0.4373403497},
|
||||
{"learn":[0.5978862443],"iteration":6,"passed_time":0.007736852993,"remaining_time":0.4343690323},
|
||||
{"learn":[0.5892253742],"iteration":7,"passed_time":0.008886826635,"remaining_time":0.4354545051},
|
||||
{"learn":[0.5808671388],"iteration":8,"passed_time":0.009982507887,"remaining_time":0.4336845093},
|
||||
{"learn":[0.5732077946],"iteration":9,"passed_time":0.01101731333,"remaining_time":0.4296752199},
|
||||
{"learn":[0.5661847426],"iteration":10,"passed_time":0.01213249484,"remaining_time":0.4290491358},
|
||||
{"learn":[0.5600289293],"iteration":11,"passed_time":0.01322150934,"remaining_time":0.4274954686},
|
||||
{"learn":[0.5530962469],"iteration":12,"passed_time":0.01425406475,"remaining_time":0.424332543},
|
||||
{"learn":[0.5481010119],"iteration":13,"passed_time":0.01530245371,"remaining_time":0.4219105093},
|
||||
{"learn":[0.5434953481],"iteration":14,"passed_time":0.0164163852,"remaining_time":0.4213538869},
|
||||
{"learn":[0.5404101637],"iteration":15,"passed_time":0.01755581704,"remaining_time":0.4213396089},
|
||||
{"learn":[0.5361341938],"iteration":16,"passed_time":0.01863220637,"remaining_time":0.4197726493},
|
||||
{"learn":[0.5317763411],"iteration":17,"passed_time":0.01970834569,"remaining_time":0.4182548919},
|
||||
{"learn":[0.5268163473],"iteration":18,"passed_time":0.02082269386,"remaining_time":0.4175498084},
|
||||
{"learn":[0.5245315654],"iteration":19,"passed_time":0.02184062408,"remaining_time":0.4149718575},
|
||||
{"learn":[0.5205327316],"iteration":20,"passed_time":0.02292138846,"remaining_time":0.413676487},
|
||||
{"learn":[0.5177701576],"iteration":21,"passed_time":0.02400340287,"remaining_time":0.4124221038},
|
||||
{"learn":[0.5137445796],"iteration":22,"passed_time":0.02504066668,"remaining_time":0.4104491886},
|
||||
{"learn":[0.5105456834],"iteration":23,"passed_time":0.02616559832,"remaining_time":0.409927707},
|
||||
{"learn":[0.5080257838],"iteration":24,"passed_time":0.02732961381,"remaining_time":0.4099442072},
|
||||
{"learn":[0.5054934276],"iteration":25,"passed_time":0.02844792037,"remaining_time":0.409212393},
|
||||
{"learn":[0.503296382],"iteration":26,"passed_time":0.02956914363,"remaining_time":0.4084922434},
|
||||
{"learn":[0.5006211207],"iteration":27,"passed_time":0.03064232458,"remaining_time":0.4071051694},
|
||||
{"learn":[0.4985921934],"iteration":28,"passed_time":0.03184809063,"remaining_time":0.4074359181},
|
||||
{"learn":[0.4961473489],"iteration":29,"passed_time":0.03302202292,"remaining_time":0.4072716161},
|
||||
{"learn":[0.4946219665],"iteration":30,"passed_time":0.03417528828,"remaining_time":0.4067961733},
|
||||
{"learn":[0.4925272328],"iteration":31,"passed_time":0.03534963724,"remaining_time":0.4065208283},
|
||||
{"learn":[0.4898936852],"iteration":32,"passed_time":0.03647952728,"remaining_time":0.405696561},
|
||||
{"learn":[0.4884288887],"iteration":33,"passed_time":0.03768625168,"remaining_time":0.4056814152},
|
||||
{"learn":[0.4863838977],"iteration":34,"passed_time":0.03874026571,"remaining_time":0.4040056281},
|
||||
{"learn":[0.4845515615],"iteration":35,"passed_time":0.03985815559,"remaining_time":0.4030102399},
|
||||
{"learn":[0.4824883347],"iteration":36,"passed_time":0.04112954752,"remaining_time":0.4035142094},
|
||||
{"learn":[0.4804030524],"iteration":37,"passed_time":0.04225827088,"remaining_time":0.4025656331},
|
||||
{"learn":[0.4785388461],"iteration":38,"passed_time":0.04337724411,"remaining_time":0.4015175672},
|
||||
{"learn":[0.4770942099],"iteration":39,"passed_time":0.04458921857,"remaining_time":0.4013029672},
|
||||
{"learn":[0.4756384413],"iteration":40,"passed_time":0.04566781626,"remaining_time":0.3998718546},
|
||||
{"learn":[0.4747696424],"iteration":41,"passed_time":0.04680949813,"remaining_time":0.398995246},
|
||||
{"learn":[0.4736129814],"iteration":42,"passed_time":0.04803018105,"remaining_time":0.3987622008},
|
||||
{"learn":[0.4725400991],"iteration":43,"passed_time":0.04913252905,"remaining_time":0.397526826},
|
||||
{"learn":[0.4712424271],"iteration":44,"passed_time":0.05019441819,"remaining_time":0.3959781879},
|
||||
{"learn":[0.4701835699],"iteration":45,"passed_time":0.05135301695,"remaining_time":0.3951949565},
|
||||
{"learn":[0.4690223311],"iteration":46,"passed_time":0.05250178224,"remaining_time":0.3943218964},
|
||||
{"learn":[0.4682401998],"iteration":47,"passed_time":0.05360408858,"remaining_time":0.3930966496},
|
||||
{"learn":[0.4663252757],"iteration":48,"passed_time":0.05468322794,"remaining_time":0.3917104696},
|
||||
{"learn":[0.4651951732],"iteration":49,"passed_time":0.05579611776,"remaining_time":0.3905728243},
|
||||
{"learn":[0.4643129126],"iteration":50,"passed_time":0.05688575727,"remaining_time":0.3892770448},
|
||||
{"learn":[0.4634919617],"iteration":51,"passed_time":0.05797056337,"remaining_time":0.3879568472},
|
||||
{"learn":[0.4627711631],"iteration":52,"passed_time":0.05911424526,"remaining_time":0.387031002},
|
||||
{"learn":[0.4618109601],"iteration":53,"passed_time":0.06020113473,"remaining_time":0.3857331966},
|
||||
{"learn":[0.460959898],"iteration":54,"passed_time":0.06127473236,"remaining_time":0.3843596848},
|
||||
{"learn":[0.4594625002],"iteration":55,"passed_time":0.06230199603,"remaining_time":0.3827122613},
|
||||
{"learn":[0.4584854101],"iteration":56,"passed_time":0.06340980245,"remaining_time":0.3815712674},
|
||||
{"learn":[0.4570498581],"iteration":57,"passed_time":0.06447248326,"remaining_time":0.3801653323},
|
||||
{"learn":[0.455880592],"iteration":58,"passed_time":0.0655374141,"remaining_time":0.3787840374},
|
||||
{"learn":[0.4550663099],"iteration":59,"passed_time":0.06660280329,"remaining_time":0.3774158853},
|
||||
{"learn":[0.4542687957],"iteration":60,"passed_time":0.06766948415,"remaining_time":0.3760648382},
|
||||
{"learn":[0.4535032807],"iteration":61,"passed_time":0.06875341525,"remaining_time":0.3748170057},
|
||||
{"learn":[0.4526542794],"iteration":62,"passed_time":0.06989509711,"remaining_time":0.3738832973},
|
||||
{"learn":[0.4514785115],"iteration":63,"passed_time":0.07101169531,"remaining_time":0.3728114004},
|
||||
{"learn":[0.4507802979],"iteration":64,"passed_time":0.07211233496,"remaining_time":0.3716558802},
|
||||
{"learn":[0.4491962574],"iteration":65,"passed_time":0.07314830709,"remaining_time":0.3701747662},
|
||||
{"learn":[0.4485895185],"iteration":66,"passed_time":0.07426457195,"remaining_time":0.3691060068},
|
||||
{"learn":[0.4478692379],"iteration":67,"passed_time":0.07539092027,"remaining_time":0.3680850813},
|
||||
{"learn":[0.4463417221],"iteration":68,"passed_time":0.07652310201,"remaining_time":0.3670890836},
|
||||
{"learn":[0.4452451739],"iteration":69,"passed_time":0.07766007548,"remaining_time":0.3661117844},
|
||||
{"learn":[0.4444830618],"iteration":70,"passed_time":0.07871713122,"remaining_time":0.3647596644},
|
||||
{"learn":[0.4435724065],"iteration":71,"passed_time":0.07978656212,"remaining_time":0.3634721163},
|
||||
{"learn":[0.4420487712],"iteration":72,"passed_time":0.08081545082,"remaining_time":0.3620089372},
|
||||
{"learn":[0.441478802],"iteration":73,"passed_time":0.08198309136,"remaining_time":0.3611687538},
|
||||
{"learn":[0.4410124289],"iteration":74,"passed_time":0.08309781453,"remaining_time":0.3600905296},
|
||||
{"learn":[0.4401138277],"iteration":75,"passed_time":0.08419895419,"remaining_time":0.3589534363},
|
||||
{"learn":[0.4394535191],"iteration":76,"passed_time":0.08528813536,"remaining_time":0.3577671133},
|
||||
{"learn":[0.4388369011],"iteration":77,"passed_time":0.08643506729,"remaining_time":0.3568216881},
|
||||
{"learn":[0.4379911776],"iteration":78,"passed_time":0.08757429079,"remaining_time":0.3558398398},
|
||||
{"learn":[0.4374327656],"iteration":79,"passed_time":0.08871480597,"remaining_time":0.3548592239},
|
||||
{"learn":[0.4364149666],"iteration":80,"passed_time":0.08976015322,"remaining_time":0.3534998627},
|
||||
{"learn":[0.4358972456],"iteration":81,"passed_time":0.09086350124,"remaining_time":0.3523730902},
|
||||
{"learn":[0.4352582245],"iteration":82,"passed_time":0.09194689067,"remaining_time":0.3511706547},
|
||||
{"learn":[0.4345396736],"iteration":83,"passed_time":0.09300957148,"remaining_time":0.3498931499},
|
||||
{"learn":[0.4341003864],"iteration":84,"passed_time":0.09409496093,"remaining_time":0.3487048552},
|
||||
{"learn":[0.4332298157],"iteration":85,"passed_time":0.09523405943,"remaining_time":0.3477150542},
|
||||
{"learn":[0.43230384],"iteration":86,"passed_time":0.09630836539,"remaining_time":0.3464887169},
|
||||
{"learn":[0.4316562364],"iteration":87,"passed_time":0.09744271383,"remaining_time":0.3454787127},
|
||||
{"learn":[0.4309618622],"iteration":88,"passed_time":0.09848635272,"remaining_time":0.3441489404},
|
||||
{"learn":[0.4298558624],"iteration":89,"passed_time":0.09950936634,"remaining_time":0.3427544841},
|
||||
{"learn":[0.4291876524],"iteration":90,"passed_time":0.100633923,"remaining_time":0.3417129912},
|
||||
{"learn":[0.4282528408],"iteration":91,"passed_time":0.1017303959,"remaining_time":0.3405756732},
|
||||
{"learn":[0.4277131957],"iteration":92,"passed_time":0.10278841,"remaining_time":0.3393122781},
|
||||
{"learn":[0.4271829294],"iteration":93,"passed_time":0.1038367156,"remaining_time":0.3380216487},
|
||||
{"learn":[0.4264580876],"iteration":94,"passed_time":0.1049022298,"remaining_time":0.3367913693},
|
||||
{"learn":[0.4253379692],"iteration":95,"passed_time":0.1059805358,"remaining_time":0.3356050301},
|
||||
{"learn":[0.424511763],"iteration":96,"passed_time":0.107145843,"remaining_time":0.3346926848},
|
||||
{"learn":[0.4239388347],"iteration":97,"passed_time":0.1083300671,"remaining_time":0.3338334721},
|
||||
{"learn":[0.4232630534],"iteration":98,"passed_time":0.1094859575,"remaining_time":0.3328815475},
|
||||
{"learn":[0.4226485557],"iteration":99,"passed_time":0.1106647232,"remaining_time":0.3319941695},
|
||||
{"learn":[0.4222437514],"iteration":100,"passed_time":0.1117923632,"remaining_time":0.3309496692},
|
||||
{"learn":[0.4213299083],"iteration":101,"passed_time":0.1128746276,"remaining_time":0.3297709708},
|
||||
{"learn":[0.4208753627],"iteration":102,"passed_time":0.1139770589,"remaining_time":0.3286522961},
|
||||
{"learn":[0.420347864],"iteration":103,"passed_time":0.1151212408,"remaining_time":0.3276527624},
|
||||
{"learn":[0.4191908122],"iteration":104,"passed_time":0.1161755049,"remaining_time":0.326397847},
|
||||
{"learn":[0.4183297442],"iteration":105,"passed_time":0.1172568109,"remaining_time":0.3252217209},
|
||||
{"learn":[0.417987752],"iteration":106,"passed_time":0.1184834106,"remaining_time":0.3244452271},
|
||||
{"learn":[0.4174588649],"iteration":107,"passed_time":0.1196537595,"remaining_time":0.3235083127},
|
||||
{"learn":[0.4169787866],"iteration":108,"passed_time":0.120715107,"remaining_time":0.3222761113},
|
||||
{"learn":[0.4159189441],"iteration":109,"passed_time":0.1218433303,"remaining_time":0.3212233254},
|
||||
{"learn":[0.4153188878],"iteration":110,"passed_time":0.1229131362,"remaining_time":0.3200170844},
|
||||
{"learn":[0.4148918317],"iteration":111,"passed_time":0.1240373595,"remaining_time":0.3189532102},
|
||||
{"learn":[0.4144564688],"iteration":112,"passed_time":0.1251508743,"remaining_time":0.3178610702},
|
||||
{"learn":[0.4138592532],"iteration":113,"passed_time":0.1262253053,"remaining_time":0.3166705028},
|
||||
{"learn":[0.4133895004],"iteration":114,"passed_time":0.1273423202,"remaining_time":0.3155874892},
|
||||
{"learn":[0.4127703464],"iteration":115,"passed_time":0.1285151691,"remaining_time":0.3146405865},
|
||||
{"learn":[0.4124298162],"iteration":116,"passed_time":0.1297458938,"remaining_time":0.3138298116},
|
||||
{"learn":[0.4120395574],"iteration":117,"passed_time":0.1308234915,"remaining_time":0.3126459713},
|
||||
{"learn":[0.4107360285],"iteration":118,"passed_time":0.1318712555,"remaining_time":0.3113934688},
|
||||
{"learn":[0.4101591941],"iteration":119,"passed_time":0.1329510198,"remaining_time":0.3102190463},
|
||||
{"learn":[0.4092665733],"iteration":120,"passed_time":0.1340602013,"remaining_time":0.3091140178},
|
||||
{"learn":[0.4088576793],"iteration":121,"passed_time":0.135163341,"remaining_time":0.307995154},
|
||||
{"learn":[0.408361342],"iteration":122,"passed_time":0.1362857726,"remaining_time":0.3069199919},
|
||||
{"learn":[0.4078673303],"iteration":123,"passed_time":0.137447538,"remaining_time":0.3059316169},
|
||||
{"learn":[0.4073910152],"iteration":124,"passed_time":0.1386097202,"remaining_time":0.3049413844},
|
||||
{"learn":[0.4066843028],"iteration":125,"passed_time":0.1397284017,"remaining_time":0.303853826},
|
||||
{"learn":[0.4062068195],"iteration":126,"passed_time":0.1408698336,"remaining_time":0.3028146817},
|
||||
{"learn":[0.4054839673],"iteration":127,"passed_time":0.1420183489,"remaining_time":0.3017889914},
|
||||
{"learn":[0.4049627816],"iteration":128,"passed_time":0.1431889478,"remaining_time":0.3008077896},
|
||||
{"learn":[0.4042386686],"iteration":129,"passed_time":0.1442632954,"remaining_time":0.2996237674},
|
||||
{"learn":[0.4036896032],"iteration":130,"passed_time":0.1453401431,"remaining_time":0.2984465534},
|
||||
{"learn":[0.4030055463],"iteration":131,"passed_time":0.1463643234,"remaining_time":0.2971639293},
|
||||
{"learn":[0.4025982201],"iteration":132,"passed_time":0.1475024636,"remaining_time":0.2961139682},
|
||||
{"learn":[0.4021507256],"iteration":133,"passed_time":0.148610145,"remaining_time":0.2950022281},
|
||||
{"learn":[0.4017130107],"iteration":134,"passed_time":0.1497692437,"remaining_time":0.2939914784},
|
||||
{"learn":[0.4010693391],"iteration":135,"passed_time":0.1509060922,"remaining_time":0.2929353554},
|
||||
{"learn":[0.400549588],"iteration":136,"passed_time":0.1520051485,"remaining_time":0.2918055041},
|
||||
{"learn":[0.3999916469],"iteration":137,"passed_time":0.1530488291,"remaining_time":0.2905709653},
|
||||
{"learn":[0.3996655064],"iteration":138,"passed_time":0.1542111362,"remaining_time":0.2895619176},
|
||||
{"learn":[0.3993175997],"iteration":139,"passed_time":0.1553874019,"remaining_time":0.2885766034},
|
||||
{"learn":[0.3989923873],"iteration":140,"passed_time":0.1565616258,"remaining_time":0.2875848304},
|
||||
{"learn":[0.3985453884],"iteration":141,"passed_time":0.1576826824,"remaining_time":0.2864938878},
|
||||
{"learn":[0.3980582085],"iteration":142,"passed_time":0.1588619064,"remaining_time":0.2855070626},
|
||||
{"learn":[0.3978472172],"iteration":143,"passed_time":0.1599966715,"remaining_time":0.2844385272},
|
||||
{"learn":[0.3973697391],"iteration":144,"passed_time":0.1611236449,"remaining_time":0.2833553755},
|
||||
{"learn":[0.3970929708],"iteration":145,"passed_time":0.1622325346,"remaining_time":0.282240163},
|
||||
{"learn":[0.3966356443],"iteration":146,"passed_time":0.1633921751,"remaining_time":0.281212383},
|
||||
{"learn":[0.3962418114],"iteration":147,"passed_time":0.1644628977,"remaining_time":0.2800314204},
|
||||
{"learn":[0.3958183212],"iteration":148,"passed_time":0.1656396633,"remaining_time":0.2790305738},
|
||||
{"learn":[0.3952962072],"iteration":149,"passed_time":0.1667435114,"remaining_time":0.2779058523},
|
||||
{"learn":[0.3947786724],"iteration":150,"passed_time":0.1677856502,"remaining_time":0.2766796484},
|
||||
{"learn":[0.3942251128],"iteration":151,"passed_time":0.1688929983,"remaining_time":0.2755622604},
|
||||
{"learn":[0.393510771],"iteration":152,"passed_time":0.1706222297,"remaining_time":0.275448959},
|
||||
{"learn":[0.3931935538],"iteration":153,"passed_time":0.1716946189,"remaining_time":0.2742654303},
|
||||
{"learn":[0.3929263145],"iteration":154,"passed_time":0.1728882598,"remaining_time":0.2732749913},
|
||||
{"learn":[0.3921994504],"iteration":155,"passed_time":0.1739467323,"remaining_time":0.2720705299},
|
||||
{"learn":[0.3918641893],"iteration":156,"passed_time":0.1750668305,"remaining_time":0.2709633109},
|
||||
{"learn":[0.391568347],"iteration":157,"passed_time":0.1762223459,"remaining_time":0.2699101753},
|
||||
{"learn":[0.3907576665],"iteration":158,"passed_time":0.1772855684,"remaining_time":0.2687158615},
|
||||
{"learn":[0.3900011029],"iteration":159,"passed_time":0.1783590827,"remaining_time":0.267538624},
|
||||
{"learn":[0.3896939448],"iteration":160,"passed_time":0.1793802212,"remaining_time":0.2662849247},
|
||||
{"learn":[0.3892669751],"iteration":161,"passed_time":0.1805231531,"remaining_time":0.2652130274},
|
||||
{"learn":[0.3887156987],"iteration":162,"passed_time":0.1816665017,"remaining_time":0.2641408644},
|
||||
{"learn":[0.3882799657],"iteration":163,"passed_time":0.1828028501,"remaining_time":0.26305776},
|
||||
{"learn":[0.3878736136],"iteration":164,"passed_time":0.1839560322,"remaining_time":0.2619979852},
|
||||
{"learn":[0.3873377012],"iteration":165,"passed_time":0.1850520051,"remaining_time":0.2608564409},
|
||||
{"learn":[0.3868683205],"iteration":166,"passed_time":0.1861906452,"remaining_time":0.2597749721},
|
||||
{"learn":[0.3863639324],"iteration":167,"passed_time":0.1872421176,"remaining_time":0.2585724481},
|
||||
{"learn":[0.3856756608],"iteration":168,"passed_time":0.1883451739,"remaining_time":0.25744222},
|
||||
{"learn":[0.3851101196],"iteration":169,"passed_time":0.1894709389,"remaining_time":0.256343035},
|
||||
{"learn":[0.3845899076],"iteration":170,"passed_time":0.1905734536,"remaining_time":0.2552124028},
|
||||
{"learn":[0.3842809463],"iteration":171,"passed_time":0.1917395108,"remaining_time":0.2541663282},
|
||||
{"learn":[0.3838979772],"iteration":172,"passed_time":0.1928156501,"remaining_time":0.2530008819},
|
||||
{"learn":[0.3835421864],"iteration":173,"passed_time":0.1939655821,"remaining_time":0.2519323078},
|
||||
{"learn":[0.3831593151],"iteration":174,"passed_time":0.1951238058,"remaining_time":0.2508734646},
|
||||
{"learn":[0.3824219971],"iteration":175,"passed_time":0.1961889867,"remaining_time":0.2496950739},
|
||||
{"learn":[0.3818750513],"iteration":176,"passed_time":0.1972604593,"remaining_time":0.2485258894},
|
||||
{"learn":[0.3814587697],"iteration":177,"passed_time":0.1984253498,"remaining_time":0.2474743126},
|
||||
{"learn":[0.3811315933],"iteration":178,"passed_time":0.1995047391,"remaining_time":0.246315907},
|
||||
{"learn":[0.3806289168],"iteration":179,"passed_time":0.2005956703,"remaining_time":0.245172486},
|
||||
{"learn":[0.3801948808],"iteration":180,"passed_time":0.2016544344,"remaining_time":0.2439907245},
|
||||
{"learn":[0.3793927537],"iteration":181,"passed_time":0.2026815314,"remaining_time":0.2427723838},
|
||||
{"learn":[0.379061847],"iteration":182,"passed_time":0.2039010477,"remaining_time":0.2417843024},
|
||||
{"learn":[0.3786859738],"iteration":183,"passed_time":0.2050741883,"remaining_time":0.2407392645},
|
||||
{"learn":[0.3783497847],"iteration":184,"passed_time":0.2063676222,"remaining_time":0.239832642},
|
||||
{"learn":[0.3780392163],"iteration":185,"passed_time":0.2075032623,"remaining_time":0.2387403125},
|
||||
{"learn":[0.3773187067],"iteration":186,"passed_time":0.2086255689,"remaining_time":0.2376323325},
|
||||
{"learn":[0.3768762307],"iteration":187,"passed_time":0.2097723758,"remaining_time":0.2365518281},
|
||||
{"learn":[0.3763556852],"iteration":188,"passed_time":0.2108025562,"remaining_time":0.2353404199},
|
||||
{"learn":[0.3756938863],"iteration":189,"passed_time":0.2118649037,"remaining_time":0.2341664725},
|
||||
{"learn":[0.3752401881],"iteration":190,"passed_time":0.2130044189,"remaining_time":0.2330781337},
|
||||
{"learn":[0.3747042165],"iteration":191,"passed_time":0.2140860166,"remaining_time":0.231926518},
|
||||
{"learn":[0.3741421572],"iteration":192,"passed_time":0.2152354486,"remaining_time":0.2308483826},
|
||||
{"learn":[0.3737531083],"iteration":193,"passed_time":0.2163026711,"remaining_time":0.2296822178},
|
||||
{"learn":[0.3729714636],"iteration":194,"passed_time":0.2173279764,"remaining_time":0.2284730008},
|
||||
{"learn":[0.3723401504],"iteration":195,"passed_time":0.2184194909,"remaining_time":0.2273345722},
|
||||
{"learn":[0.3717195748],"iteration":196,"passed_time":0.2195059221,"remaining_time":0.2261913816},
|
||||
{"learn":[0.3713120882],"iteration":197,"passed_time":0.220651104,"remaining_time":0.225108702},
|
||||
{"learn":[0.3706316865],"iteration":198,"passed_time":0.2217496603,"remaining_time":0.2239783001},
|
||||
{"learn":[0.3702966116],"iteration":199,"passed_time":0.2229138841,"remaining_time":0.2229138841},
|
||||
{"learn":[0.3697721904],"iteration":200,"passed_time":0.2240036069,"remaining_time":0.2217747153},
|
||||
{"learn":[0.3690342594],"iteration":201,"passed_time":0.2250807463,"remaining_time":0.2206237018},
|
||||
{"learn":[0.3685483475],"iteration":202,"passed_time":0.2262793039,"remaining_time":0.2195912457},
|
||||
{"learn":[0.3679488892],"iteration":203,"passed_time":0.2273438597,"remaining_time":0.2184284143},
|
||||
{"learn":[0.3674652876],"iteration":204,"passed_time":0.2285949181,"remaining_time":0.2174439465},
|
||||
{"learn":[0.3661867815],"iteration":205,"passed_time":0.2296574322,"remaining_time":0.2162793294},
|
||||
{"learn":[0.3655245649],"iteration":206,"passed_time":0.2307709887,"remaining_time":0.215163289},
|
||||
{"learn":[0.3651419912],"iteration":207,"passed_time":0.2319487544,"remaining_time":0.2141065425},
|
||||
{"learn":[0.3648638467],"iteration":208,"passed_time":0.2331167699,"remaining_time":0.2130397275},
|
||||
{"learn":[0.3645890135],"iteration":209,"passed_time":0.234272952,"remaining_time":0.2119612423},
|
||||
{"learn":[0.3641188983],"iteration":210,"passed_time":0.2353604665,"remaining_time":0.2108205126},
|
||||
{"learn":[0.3636023273],"iteration":211,"passed_time":0.2365067734,"remaining_time":0.2097324217},
|
||||
{"learn":[0.3625971287],"iteration":212,"passed_time":0.237603163,"remaining_time":0.20859996},
|
||||
{"learn":[0.3620963436],"iteration":213,"passed_time":0.2387020943,"remaining_time":0.2074700446},
|
||||
{"learn":[0.3613752339],"iteration":214,"passed_time":0.239779317,"remaining_time":0.2063217378},
|
||||
{"learn":[0.3609288026],"iteration":215,"passed_time":0.2409774579,"remaining_time":0.2052770938},
|
||||
{"learn":[0.3602546044],"iteration":216,"passed_time":0.2420783892,"remaining_time":0.2041490563},
|
||||
{"learn":[0.3596176626],"iteration":217,"passed_time":0.2431287365,"remaining_time":0.2029790369},
|
||||
{"learn":[0.3591174894],"iteration":218,"passed_time":0.2443525445,"remaining_time":0.2019534728},
|
||||
{"learn":[0.3584672055],"iteration":219,"passed_time":0.2454519758,"remaining_time":0.2008243438},
|
||||
{"learn":[0.3579661615],"iteration":220,"passed_time":0.2465854492,"remaining_time":0.1997230562},
|
||||
{"learn":[0.3575125863],"iteration":221,"passed_time":0.2476947973,"remaining_time":0.1986021348},
|
||||
{"learn":[0.3570908255],"iteration":222,"passed_time":0.2488168539,"remaining_time":0.1974914042},
|
||||
{"learn":[0.3565320443],"iteration":223,"passed_time":0.2499274937,"remaining_time":0.1963716022},
|
||||
{"learn":[0.3557740348],"iteration":224,"passed_time":0.2510059664,"remaining_time":0.1952268628},
|
||||
{"learn":[0.3552039883],"iteration":225,"passed_time":0.2521369815,"remaining_time":0.1941231627},
|
||||
{"learn":[0.3546823154],"iteration":226,"passed_time":0.2532487879,"remaining_time":0.1930045829},
|
||||
{"learn":[0.3542588096],"iteration":227,"passed_time":0.2543872197,"remaining_time":0.1919061482},
|
||||
{"learn":[0.3539054745],"iteration":228,"passed_time":0.2556031526,"remaining_time":0.1908652362},
|
||||
{"learn":[0.3532278683],"iteration":229,"passed_time":0.2566931254,"remaining_time":0.1897297014},
|
||||
{"learn":[0.3529230362],"iteration":230,"passed_time":0.2578798912,"remaining_time":0.188665375},
|
||||
{"learn":[0.352381597],"iteration":231,"passed_time":0.2589980311,"remaining_time":0.1875502984},
|
||||
{"learn":[0.3518928383],"iteration":232,"passed_time":0.2601070459,"remaining_time":0.1864286552},
|
||||
{"learn":[0.3513050813],"iteration":233,"passed_time":0.2611858102,"remaining_time":0.1852856603},
|
||||
{"learn":[0.3508996451],"iteration":234,"passed_time":0.262347159,"remaining_time":0.1842011968},
|
||||
{"learn":[0.3504190546],"iteration":235,"passed_time":0.2635076745,"remaining_time":0.1831155026},
|
||||
{"learn":[0.350020568],"iteration":236,"passed_time":0.2645913556,"remaining_time":0.1819763332},
|
||||
{"learn":[0.3495522954],"iteration":237,"passed_time":0.265650578,"remaining_time":0.1808209817},
|
||||
{"learn":[0.349180171],"iteration":238,"passed_time":0.2667622178,"remaining_time":0.1797017451},
|
||||
{"learn":[0.3488403456],"iteration":239,"passed_time":0.2679780257,"remaining_time":0.1786520171},
|
||||
{"learn":[0.348326175],"iteration":240,"passed_time":0.2690999573,"remaining_time":0.177538976},
|
||||
{"learn":[0.3480609146],"iteration":241,"passed_time":0.2704532669,"remaining_time":0.1765769264},
|
||||
{"learn":[0.3474846933],"iteration":242,"passed_time":0.271532448,"remaining_time":0.1754345446},
|
||||
{"learn":[0.3470838691],"iteration":243,"passed_time":0.2727193804,"remaining_time":0.1743615711},
|
||||
{"learn":[0.3464878166],"iteration":244,"passed_time":0.2737749778,"remaining_time":0.1732045778},
|
||||
{"learn":[0.3461395179],"iteration":245,"passed_time":0.2749240348,"remaining_time":0.1721069161},
|
||||
{"learn":[0.3452807894],"iteration":246,"passed_time":0.2759993824,"remaining_time":0.1709631802},
|
||||
{"learn":[0.3449142029],"iteration":247,"passed_time":0.2772472741,"remaining_time":0.1699257486},
|
||||
{"learn":[0.3443799395],"iteration":248,"passed_time":0.2783343302,"remaining_time":0.1687890918},
|
||||
{"learn":[0.3438780899],"iteration":249,"passed_time":0.2794902206,"remaining_time":0.1676941324},
|
||||
{"learn":[0.343511803],"iteration":250,"passed_time":0.2805435263,"remaining_time":0.1665377905},
|
||||
{"learn":[0.3430115446],"iteration":251,"passed_time":0.2816808747,"remaining_time":0.1654316249},
|
||||
{"learn":[0.3424726164],"iteration":252,"passed_time":0.2828335984,"remaining_time":0.1643341461},
|
||||
{"learn":[0.3420562225],"iteration":253,"passed_time":0.2839551134,"remaining_time":0.1632182935},
|
||||
{"learn":[0.34149691],"iteration":254,"passed_time":0.285008294,"remaining_time":0.1620635397},
|
||||
{"learn":[0.3409610654],"iteration":255,"passed_time":0.2860447662,"remaining_time":0.160900181},
|
||||
{"learn":[0.3405231536],"iteration":256,"passed_time":0.2871926148,"remaining_time":0.1597997818},
|
||||
{"learn":[0.340034093],"iteration":257,"passed_time":0.2882568373,"remaining_time":0.158652988},
|
||||
{"learn":[0.3397309627],"iteration":258,"passed_time":0.2893273515,"remaining_time":0.157510257},
|
||||
{"learn":[0.339253501],"iteration":259,"passed_time":0.2904178244,"remaining_time":0.1563788285},
|
||||
{"learn":[0.3388066139],"iteration":260,"passed_time":0.2915355476,"remaining_time":0.1552622265},
|
||||
{"learn":[0.3384464664],"iteration":261,"passed_time":0.292620937,"remaining_time":0.1541285852},
|
||||
{"learn":[0.3379404375],"iteration":262,"passed_time":0.2936824928,"remaining_time":0.1529828955},
|
||||
{"learn":[0.3375414354],"iteration":263,"passed_time":0.2948104245,"remaining_time":0.1518720369},
|
||||
{"learn":[0.3370821259],"iteration":264,"passed_time":0.295924856,"remaining_time":0.1507541719},
|
||||
{"learn":[0.336602236],"iteration":265,"passed_time":0.2970121205,"remaining_time":0.1496226472},
|
||||
{"learn":[0.3362749],"iteration":266,"passed_time":0.2981132185,"remaining_time":0.1484983448},
|
||||
{"learn":[0.3356858224],"iteration":267,"passed_time":0.2991777743,"remaining_time":0.1473562172},
|
||||
{"learn":[0.3352310019],"iteration":268,"passed_time":0.3003209145,"remaining_time":0.1462529361},
|
||||
{"learn":[0.3348569493],"iteration":269,"passed_time":0.3014208042,"remaining_time":0.1451285354},
|
||||
{"learn":[0.3343571837],"iteration":270,"passed_time":0.3025719445,"remaining_time":0.1440287116},
|
||||
{"learn":[0.333972653],"iteration":271,"passed_time":0.3036274169,"remaining_time":0.1428834903},
|
||||
{"learn":[0.3334731775],"iteration":272,"passed_time":0.3047476818,"remaining_time":0.1417690681},
|
||||
{"learn":[0.3330291212],"iteration":273,"passed_time":0.3058505715,"remaining_time":0.1406466132},
|
||||
{"learn":[0.3326605023],"iteration":274,"passed_time":0.3069655863,"remaining_time":0.139529812},
|
||||
{"learn":[0.3321437127],"iteration":275,"passed_time":0.3080452674,"remaining_time":0.1383971491},
|
||||
{"learn":[0.3315365701],"iteration":276,"passed_time":0.3091012398,"remaining_time":0.1372543411},
|
||||
{"learn":[0.3310604688],"iteration":277,"passed_time":0.3101988377,"remaining_time":0.1361304252},
|
||||
{"learn":[0.3306178809],"iteration":278,"passed_time":0.3113700616,"remaining_time":0.1350386289},
|
||||
{"learn":[0.3302189522],"iteration":279,"passed_time":0.3124655346,"remaining_time":0.1339138005},
|
||||
{"learn":[0.3298908388],"iteration":280,"passed_time":0.3135639658,"remaining_time":0.1327904339},
|
||||
{"learn":[0.3296290713],"iteration":281,"passed_time":0.3147306064,"remaining_time":0.1316957856},
|
||||
{"learn":[0.3292322275],"iteration":282,"passed_time":0.3159200389,"remaining_time":0.1306100514},
|
||||
{"learn":[0.3289530144],"iteration":283,"passed_time":0.3171967225,"remaining_time":0.1295592247},
|
||||
{"learn":[0.3283868788],"iteration":284,"passed_time":0.3182564866,"remaining_time":0.1284192841},
|
||||
{"learn":[0.3279859547],"iteration":285,"passed_time":0.3193458345,"remaining_time":0.1272916963},
|
||||
{"learn":[0.3276029024],"iteration":286,"passed_time":0.3205133917,"remaining_time":0.1261951682},
|
||||
{"learn":[0.3269980903],"iteration":287,"passed_time":0.3216701571,"remaining_time":0.12509395},
|
||||
{"learn":[0.3265024345],"iteration":288,"passed_time":0.3228997151,"remaining_time":0.1240203058},
|
||||
{"learn":[0.3260926102],"iteration":289,"passed_time":0.3239976464,"remaining_time":0.122895659},
|
||||
{"learn":[0.3255902536],"iteration":290,"passed_time":0.3250561605,"remaining_time":0.1217564312},
|
||||
{"learn":[0.3253374601],"iteration":291,"passed_time":0.3262455513,"remaining_time":0.1206661628},
|
||||
{"learn":[0.3249964957],"iteration":292,"passed_time":0.3274385255,"remaining_time":0.1195765264},
|
||||
{"learn":[0.3247110169],"iteration":293,"passed_time":0.3286553334,"remaining_time":0.1184947801},
|
||||
{"learn":[0.3244365598],"iteration":294,"passed_time":0.3297882652,"remaining_time":0.1173822639},
|
||||
{"learn":[0.3236145686],"iteration":295,"passed_time":0.3309152385,"remaining_time":0.1162675162},
|
||||
{"learn":[0.3232270981],"iteration":296,"passed_time":0.332130463,"remaining_time":0.1151832919},
|
||||
{"learn":[0.3228851393],"iteration":297,"passed_time":0.3332317693,"remaining_time":0.1140591962},
|
||||
{"learn":[0.3225358685],"iteration":298,"passed_time":0.3343837013,"remaining_time":0.112952354},
|
||||
{"learn":[0.3221528653],"iteration":299,"passed_time":0.3356189678,"remaining_time":0.1118729893},
|
||||
{"learn":[0.3214501982],"iteration":300,"passed_time":0.3367013988,"remaining_time":0.1107423206},
|
||||
{"learn":[0.320997221],"iteration":301,"passed_time":0.3378206637,"remaining_time":0.109623924},
|
||||
{"learn":[0.3206101631],"iteration":302,"passed_time":0.3389297202,"remaining_time":0.1085022537},
|
||||
{"learn":[0.3201732621],"iteration":303,"passed_time":0.3399921927,"remaining_time":0.1073659556},
|
||||
{"learn":[0.3199084998],"iteration":304,"passed_time":0.3411286661,"remaining_time":0.1062531911},
|
||||
{"learn":[0.3195992788],"iteration":305,"passed_time":0.3422892649,"remaining_time":0.1051476827},
|
||||
{"learn":[0.3191488459],"iteration":306,"passed_time":0.3433914879,"remaining_time":0.1040241315},
|
||||
{"learn":[0.3187874781],"iteration":307,"passed_time":0.3444620855,"remaining_time":0.1028912723},
|
||||
{"learn":[0.3185523705],"iteration":308,"passed_time":0.3456197676,"remaining_time":0.1017844623},
|
||||
{"learn":[0.3183052639],"iteration":309,"passed_time":0.3467240323,"remaining_time":0.1006618158},
|
||||
{"learn":[0.3179523493],"iteration":310,"passed_time":0.3479116314,"remaining_time":0.09956313568},
|
||||
{"learn":[0.3173939542],"iteration":311,"passed_time":0.3490191878,"remaining_time":0.09844130939},
|
||||
{"learn":[0.3170235217],"iteration":312,"passed_time":0.3500825353,"remaining_time":0.09730728617},
|
||||
{"learn":[0.3167426475],"iteration":313,"passed_time":0.3512368007,"remaining_time":0.0961986142},
|
||||
{"learn":[0.3163718121],"iteration":314,"passed_time":0.3523208568,"remaining_time":0.09507070738},
|
||||
{"learn":[0.3158370493],"iteration":315,"passed_time":0.3534916224,"remaining_time":0.09396612746},
|
||||
{"learn":[0.3155503527],"iteration":316,"passed_time":0.3545707201,"remaining_time":0.0928371286},
|
||||
{"learn":[0.3151236337],"iteration":317,"passed_time":0.3557036935,"remaining_time":0.09172233605},
|
||||
{"learn":[0.3148689295],"iteration":318,"passed_time":0.3567603742,"remaining_time":0.0905880574},
|
||||
{"learn":[0.3146299768],"iteration":319,"passed_time":0.3578028881,"remaining_time":0.08945072202},
|
||||
{"learn":[0.3142772407],"iteration":320,"passed_time":0.3588606938,"remaining_time":0.08831774085},
|
||||
{"learn":[0.3138530784],"iteration":321,"passed_time":0.360001834,"remaining_time":0.08720541321},
|
||||
{"learn":[0.3135854205],"iteration":322,"passed_time":0.3611158489,"remaining_time":0.08608644075},
|
||||
{"learn":[0.3131214904],"iteration":323,"passed_time":0.3621631545,"remaining_time":0.08495185105},
|
||||
{"learn":[0.3127659838],"iteration":324,"passed_time":0.3632967112,"remaining_time":0.08383770259},
|
||||
{"learn":[0.3122350721],"iteration":325,"passed_time":0.3643763506,"remaining_time":0.08271119615},
|
||||
{"learn":[0.3118475636],"iteration":326,"passed_time":0.3655228659,"remaining_time":0.08159990583},
|
||||
{"learn":[0.3115344437],"iteration":327,"passed_time":0.3666650894,"remaining_time":0.08048745865},
|
||||
{"learn":[0.311237246],"iteration":328,"passed_time":0.3677735625,"remaining_time":0.07936754692},
|
||||
{"learn":[0.3109110889],"iteration":329,"passed_time":0.3688446184,"remaining_time":0.07823976754},
|
||||
{"learn":[0.310639938],"iteration":330,"passed_time":0.37009251,"remaining_time":0.07714919393},
|
||||
{"learn":[0.3103155862],"iteration":331,"passed_time":0.3711809828,"remaining_time":0.07602502058},
|
||||
{"learn":[0.3098221248],"iteration":332,"passed_time":0.3723168313,"remaining_time":0.07491059368},
|
||||
{"learn":[0.309423914],"iteration":333,"passed_time":0.3734389712,"remaining_time":0.07379332964},
|
||||
{"learn":[0.3091671621],"iteration":334,"passed_time":0.3746966546,"remaining_time":0.07270233598},
|
||||
{"learn":[0.308852111],"iteration":335,"passed_time":0.3758094611,"remaining_time":0.0715827545},
|
||||
{"learn":[0.3084452031],"iteration":336,"passed_time":0.3769338511,"remaining_time":0.07046537869},
|
||||
{"learn":[0.30805284],"iteration":337,"passed_time":0.3780220739,"remaining_time":0.06934132717},
|
||||
{"learn":[0.307790852],"iteration":338,"passed_time":0.3791067133,"remaining_time":0.06821684222},
|
||||
{"learn":[0.3075070726],"iteration":339,"passed_time":0.3801461439,"remaining_time":0.06708461362},
|
||||
{"learn":[0.3070106772],"iteration":340,"passed_time":0.3812151164,"remaining_time":0.06595804067},
|
||||
{"learn":[0.3063522606],"iteration":341,"passed_time":0.3823247145,"remaining_time":0.06483869428},
|
||||
{"learn":[0.306023137],"iteration":342,"passed_time":0.3834944384,"remaining_time":0.06372939647},
|
||||
{"learn":[0.3056081686],"iteration":343,"passed_time":0.3845728694,"remaining_time":0.06260488572},
|
||||
{"learn":[0.3052908972],"iteration":344,"passed_time":0.3857046345,"remaining_time":0.06148914463},
|
||||
{"learn":[0.3050698337],"iteration":345,"passed_time":0.3867824405,"remaining_time":0.06036488956},
|
||||
{"learn":[0.304718801],"iteration":346,"passed_time":0.3878819552,"remaining_time":0.05924421794},
|
||||
{"learn":[0.3043544625],"iteration":347,"passed_time":0.3890576375,"remaining_time":0.05813504928},
|
||||
{"learn":[0.3041033502],"iteration":348,"passed_time":0.3902497784,"remaining_time":0.05702790457},
|
||||
{"learn":[0.3037743316],"iteration":349,"passed_time":0.3913301677,"remaining_time":0.05590430968},
|
||||
{"learn":[0.3034668293],"iteration":350,"passed_time":0.392504225,"remaining_time":0.05479403711},
|
||||
{"learn":[0.3030885587],"iteration":351,"passed_time":0.3938031173,"remaining_time":0.05370042509},
|
||||
{"learn":[0.3026812327],"iteration":352,"passed_time":0.3948736316,"remaining_time":0.05257524273},
|
||||
{"learn":[0.3021014274],"iteration":353,"passed_time":0.3959924381,"remaining_time":0.0514566445},
|
||||
{"learn":[0.3018628727],"iteration":354,"passed_time":0.3971618287,"remaining_time":0.05034445716},
|
||||
{"learn":[0.3015681515],"iteration":355,"passed_time":0.398210676,"remaining_time":0.04921704984},
|
||||
{"learn":[0.3012563129],"iteration":356,"passed_time":0.3994373173,"remaining_time":0.0481114976},
|
||||
{"learn":[0.3008425713],"iteration":357,"passed_time":0.4005401653,"remaining_time":0.04699074565},
|
||||
{"learn":[0.3006504824],"iteration":358,"passed_time":0.4017283478,"remaining_time":0.04587983917},
|
||||
{"learn":[0.3002997122],"iteration":359,"passed_time":0.4028637796,"remaining_time":0.04476264218},
|
||||
{"learn":[0.29986022],"iteration":360,"passed_time":0.4039345855,"remaining_time":0.04363836243},
|
||||
{"learn":[0.2994157375],"iteration":361,"passed_time":0.4049831411,"remaining_time":0.04251204244},
|
||||
{"learn":[0.2991488897],"iteration":362,"passed_time":0.4060736973,"remaining_time":0.04139043196},
|
||||
{"learn":[0.2987604674],"iteration":363,"passed_time":0.4071648369,"remaining_time":0.0402690498},
|
||||
{"learn":[0.2984520322],"iteration":364,"passed_time":0.4083211439,"remaining_time":0.03915408229},
|
||||
{"learn":[0.2980086594],"iteration":365,"passed_time":0.4094280337,"remaining_time":0.03803429821},
|
||||
{"learn":[0.2976722806],"iteration":366,"passed_time":0.4105029646,"remaining_time":0.03691171072},
|
||||
{"learn":[0.297418779],"iteration":367,"passed_time":0.4116947305,"remaining_time":0.03579954178},
|
||||
{"learn":[0.2970540834],"iteration":368,"passed_time":0.4128054119,"remaining_time":0.03468012946},
|
||||
{"learn":[0.2968505628],"iteration":369,"passed_time":0.4138733428,"remaining_time":0.03355729807},
|
||||
{"learn":[0.2966096352],"iteration":370,"passed_time":0.4149656907,"remaining_time":0.03243667124},
|
||||
{"learn":[0.2962534879],"iteration":371,"passed_time":0.4159768292,"remaining_time":0.03131008392},
|
||||
{"learn":[0.2956966575],"iteration":372,"passed_time":0.4170019261,"remaining_time":0.03018512602},
|
||||
{"learn":[0.295467724],"iteration":373,"passed_time":0.4181140243,"remaining_time":0.02906675035},
|
||||
{"learn":[0.295198672],"iteration":374,"passed_time":0.4192409559,"remaining_time":0.02794939706},
|
||||
{"learn":[0.2948654216],"iteration":375,"passed_time":0.4202776364,"remaining_time":0.02682623211},
|
||||
{"learn":[0.2944509322],"iteration":376,"passed_time":0.4213771094,"remaining_time":0.02570735681},
|
||||
{"learn":[0.294163659],"iteration":377,"passed_time":0.4226436679,"remaining_time":0.02459830871},
|
||||
{"learn":[0.2938644764],"iteration":378,"passed_time":0.4237322241,"remaining_time":0.02347856651},
|
||||
{"learn":[0.293532816],"iteration":379,"passed_time":0.4248420722,"remaining_time":0.02236010906},
|
||||
{"learn":[0.2932769543],"iteration":380,"passed_time":0.4259474202,"remaining_time":0.0212414724},
|
||||
{"learn":[0.2930012713],"iteration":381,"passed_time":0.4270412265,"remaining_time":0.02012236146},
|
||||
{"learn":[0.2927528101],"iteration":382,"passed_time":0.4281576163,"remaining_time":0.01900438506},
|
||||
{"learn":[0.2924546703],"iteration":383,"passed_time":0.4292129637,"remaining_time":0.01788387349},
|
||||
{"learn":[0.2921348133],"iteration":384,"passed_time":0.4303516039,"remaining_time":0.0167669456},
|
||||
{"learn":[0.2918413938],"iteration":385,"passed_time":0.4314503685,"remaining_time":0.01564845896},
|
||||
{"learn":[0.2914998283],"iteration":386,"passed_time":0.4325481331,"remaining_time":0.01453004065},
|
||||
{"learn":[0.2912741093],"iteration":387,"passed_time":0.4336954817,"remaining_time":0.01341326232},
|
||||
{"learn":[0.2910467504],"iteration":388,"passed_time":0.4347749961,"remaining_time":0.01229440863},
|
||||
{"learn":[0.2908811787],"iteration":389,"passed_time":0.4359572618,"remaining_time":0.01117839133},
|
||||
{"learn":[0.29031764],"iteration":390,"passed_time":0.4370190259,"remaining_time":0.01005926147},
|
||||
{"learn":[0.2900000009],"iteration":391,"passed_time":0.4381199989,"remaining_time":0.008941224468},
|
||||
{"learn":[0.2897507124],"iteration":392,"passed_time":0.4392080968,"remaining_time":0.00782304498},
|
||||
{"learn":[0.2895248451],"iteration":393,"passed_time":0.4403091947,"remaining_time":0.006705216164},
|
||||
{"learn":[0.2892178364],"iteration":394,"passed_time":0.4414087927,"remaining_time":0.005587453072},
|
||||
{"learn":[0.2888956874],"iteration":395,"passed_time":0.442581475,"remaining_time":0.004470519949},
|
||||
{"learn":[0.2885872177],"iteration":396,"passed_time":0.443805658,"remaining_time":0.003353695148},
|
||||
{"learn":[0.2883226548],"iteration":397,"passed_time":0.4449120477,"remaining_time":0.002235738933},
|
||||
{"learn":[0.2880616544],"iteration":398,"passed_time":0.4460379793,"remaining_time":0.001117889673},
|
||||
{"learn":[0.2877225749],"iteration":399,"passed_time":0.4471239521,"remaining_time":0}
|
||||
]}
|
||||
@@ -1,401 +0,0 @@
|
||||
iter Logloss
|
||||
0 0.6752574527
|
||||
1 0.6590158329
|
||||
2 0.6439053461
|
||||
3 0.6300318652
|
||||
4 0.6176080869
|
||||
5 0.6072057723
|
||||
6 0.5978862443
|
||||
7 0.5892253742
|
||||
8 0.5808671388
|
||||
9 0.5732077946
|
||||
10 0.5661847426
|
||||
11 0.5600289293
|
||||
12 0.5530962469
|
||||
13 0.5481010119
|
||||
14 0.5434953481
|
||||
15 0.5404101637
|
||||
16 0.5361341938
|
||||
17 0.5317763411
|
||||
18 0.5268163473
|
||||
19 0.5245315654
|
||||
20 0.5205327316
|
||||
21 0.5177701576
|
||||
22 0.5137445796
|
||||
23 0.5105456834
|
||||
24 0.5080257838
|
||||
25 0.5054934276
|
||||
26 0.503296382
|
||||
27 0.5006211207
|
||||
28 0.4985921934
|
||||
29 0.4961473489
|
||||
30 0.4946219665
|
||||
31 0.4925272328
|
||||
32 0.4898936852
|
||||
33 0.4884288887
|
||||
34 0.4863838977
|
||||
35 0.4845515615
|
||||
36 0.4824883347
|
||||
37 0.4804030524
|
||||
38 0.4785388461
|
||||
39 0.4770942099
|
||||
40 0.4756384413
|
||||
41 0.4747696424
|
||||
42 0.4736129814
|
||||
43 0.4725400991
|
||||
44 0.4712424271
|
||||
45 0.4701835699
|
||||
46 0.4690223311
|
||||
47 0.4682401998
|
||||
48 0.4663252757
|
||||
49 0.4651951732
|
||||
50 0.4643129126
|
||||
51 0.4634919617
|
||||
52 0.4627711631
|
||||
53 0.4618109601
|
||||
54 0.460959898
|
||||
55 0.4594625002
|
||||
56 0.4584854101
|
||||
57 0.4570498581
|
||||
58 0.455880592
|
||||
59 0.4550663099
|
||||
60 0.4542687957
|
||||
61 0.4535032807
|
||||
62 0.4526542794
|
||||
63 0.4514785115
|
||||
64 0.4507802979
|
||||
65 0.4491962574
|
||||
66 0.4485895185
|
||||
67 0.4478692379
|
||||
68 0.4463417221
|
||||
69 0.4452451739
|
||||
70 0.4444830618
|
||||
71 0.4435724065
|
||||
72 0.4420487712
|
||||
73 0.441478802
|
||||
74 0.4410124289
|
||||
75 0.4401138277
|
||||
76 0.4394535191
|
||||
77 0.4388369011
|
||||
78 0.4379911776
|
||||
79 0.4374327656
|
||||
80 0.4364149666
|
||||
81 0.4358972456
|
||||
82 0.4352582245
|
||||
83 0.4345396736
|
||||
84 0.4341003864
|
||||
85 0.4332298157
|
||||
86 0.43230384
|
||||
87 0.4316562364
|
||||
88 0.4309618622
|
||||
89 0.4298558624
|
||||
90 0.4291876524
|
||||
91 0.4282528408
|
||||
92 0.4277131957
|
||||
93 0.4271829294
|
||||
94 0.4264580876
|
||||
95 0.4253379692
|
||||
96 0.424511763
|
||||
97 0.4239388347
|
||||
98 0.4232630534
|
||||
99 0.4226485557
|
||||
100 0.4222437514
|
||||
101 0.4213299083
|
||||
102 0.4208753627
|
||||
103 0.420347864
|
||||
104 0.4191908122
|
||||
105 0.4183297442
|
||||
106 0.417987752
|
||||
107 0.4174588649
|
||||
108 0.4169787866
|
||||
109 0.4159189441
|
||||
110 0.4153188878
|
||||
111 0.4148918317
|
||||
112 0.4144564688
|
||||
113 0.4138592532
|
||||
114 0.4133895004
|
||||
115 0.4127703464
|
||||
116 0.4124298162
|
||||
117 0.4120395574
|
||||
118 0.4107360285
|
||||
119 0.4101591941
|
||||
120 0.4092665733
|
||||
121 0.4088576793
|
||||
122 0.408361342
|
||||
123 0.4078673303
|
||||
124 0.4073910152
|
||||
125 0.4066843028
|
||||
126 0.4062068195
|
||||
127 0.4054839673
|
||||
128 0.4049627816
|
||||
129 0.4042386686
|
||||
130 0.4036896032
|
||||
131 0.4030055463
|
||||
132 0.4025982201
|
||||
133 0.4021507256
|
||||
134 0.4017130107
|
||||
135 0.4010693391
|
||||
136 0.400549588
|
||||
137 0.3999916469
|
||||
138 0.3996655064
|
||||
139 0.3993175997
|
||||
140 0.3989923873
|
||||
141 0.3985453884
|
||||
142 0.3980582085
|
||||
143 0.3978472172
|
||||
144 0.3973697391
|
||||
145 0.3970929708
|
||||
146 0.3966356443
|
||||
147 0.3962418114
|
||||
148 0.3958183212
|
||||
149 0.3952962072
|
||||
150 0.3947786724
|
||||
151 0.3942251128
|
||||
152 0.393510771
|
||||
153 0.3931935538
|
||||
154 0.3929263145
|
||||
155 0.3921994504
|
||||
156 0.3918641893
|
||||
157 0.391568347
|
||||
158 0.3907576665
|
||||
159 0.3900011029
|
||||
160 0.3896939448
|
||||
161 0.3892669751
|
||||
162 0.3887156987
|
||||
163 0.3882799657
|
||||
164 0.3878736136
|
||||
165 0.3873377012
|
||||
166 0.3868683205
|
||||
167 0.3863639324
|
||||
168 0.3856756608
|
||||
169 0.3851101196
|
||||
170 0.3845899076
|
||||
171 0.3842809463
|
||||
172 0.3838979772
|
||||
173 0.3835421864
|
||||
174 0.3831593151
|
||||
175 0.3824219971
|
||||
176 0.3818750513
|
||||
177 0.3814587697
|
||||
178 0.3811315933
|
||||
179 0.3806289168
|
||||
180 0.3801948808
|
||||
181 0.3793927537
|
||||
182 0.379061847
|
||||
183 0.3786859738
|
||||
184 0.3783497847
|
||||
185 0.3780392163
|
||||
186 0.3773187067
|
||||
187 0.3768762307
|
||||
188 0.3763556852
|
||||
189 0.3756938863
|
||||
190 0.3752401881
|
||||
191 0.3747042165
|
||||
192 0.3741421572
|
||||
193 0.3737531083
|
||||
194 0.3729714636
|
||||
195 0.3723401504
|
||||
196 0.3717195748
|
||||
197 0.3713120882
|
||||
198 0.3706316865
|
||||
199 0.3702966116
|
||||
200 0.3697721904
|
||||
201 0.3690342594
|
||||
202 0.3685483475
|
||||
203 0.3679488892
|
||||
204 0.3674652876
|
||||
205 0.3661867815
|
||||
206 0.3655245649
|
||||
207 0.3651419912
|
||||
208 0.3648638467
|
||||
209 0.3645890135
|
||||
210 0.3641188983
|
||||
211 0.3636023273
|
||||
212 0.3625971287
|
||||
213 0.3620963436
|
||||
214 0.3613752339
|
||||
215 0.3609288026
|
||||
216 0.3602546044
|
||||
217 0.3596176626
|
||||
218 0.3591174894
|
||||
219 0.3584672055
|
||||
220 0.3579661615
|
||||
221 0.3575125863
|
||||
222 0.3570908255
|
||||
223 0.3565320443
|
||||
224 0.3557740348
|
||||
225 0.3552039883
|
||||
226 0.3546823154
|
||||
227 0.3542588096
|
||||
228 0.3539054745
|
||||
229 0.3532278683
|
||||
230 0.3529230362
|
||||
231 0.352381597
|
||||
232 0.3518928383
|
||||
233 0.3513050813
|
||||
234 0.3508996451
|
||||
235 0.3504190546
|
||||
236 0.350020568
|
||||
237 0.3495522954
|
||||
238 0.349180171
|
||||
239 0.3488403456
|
||||
240 0.348326175
|
||||
241 0.3480609146
|
||||
242 0.3474846933
|
||||
243 0.3470838691
|
||||
244 0.3464878166
|
||||
245 0.3461395179
|
||||
246 0.3452807894
|
||||
247 0.3449142029
|
||||
248 0.3443799395
|
||||
249 0.3438780899
|
||||
250 0.343511803
|
||||
251 0.3430115446
|
||||
252 0.3424726164
|
||||
253 0.3420562225
|
||||
254 0.34149691
|
||||
255 0.3409610654
|
||||
256 0.3405231536
|
||||
257 0.340034093
|
||||
258 0.3397309627
|
||||
259 0.339253501
|
||||
260 0.3388066139
|
||||
261 0.3384464664
|
||||
262 0.3379404375
|
||||
263 0.3375414354
|
||||
264 0.3370821259
|
||||
265 0.336602236
|
||||
266 0.3362749
|
||||
267 0.3356858224
|
||||
268 0.3352310019
|
||||
269 0.3348569493
|
||||
270 0.3343571837
|
||||
271 0.333972653
|
||||
272 0.3334731775
|
||||
273 0.3330291212
|
||||
274 0.3326605023
|
||||
275 0.3321437127
|
||||
276 0.3315365701
|
||||
277 0.3310604688
|
||||
278 0.3306178809
|
||||
279 0.3302189522
|
||||
280 0.3298908388
|
||||
281 0.3296290713
|
||||
282 0.3292322275
|
||||
283 0.3289530144
|
||||
284 0.3283868788
|
||||
285 0.3279859547
|
||||
286 0.3276029024
|
||||
287 0.3269980903
|
||||
288 0.3265024345
|
||||
289 0.3260926102
|
||||
290 0.3255902536
|
||||
291 0.3253374601
|
||||
292 0.3249964957
|
||||
293 0.3247110169
|
||||
294 0.3244365598
|
||||
295 0.3236145686
|
||||
296 0.3232270981
|
||||
297 0.3228851393
|
||||
298 0.3225358685
|
||||
299 0.3221528653
|
||||
300 0.3214501982
|
||||
301 0.320997221
|
||||
302 0.3206101631
|
||||
303 0.3201732621
|
||||
304 0.3199084998
|
||||
305 0.3195992788
|
||||
306 0.3191488459
|
||||
307 0.3187874781
|
||||
308 0.3185523705
|
||||
309 0.3183052639
|
||||
310 0.3179523493
|
||||
311 0.3173939542
|
||||
312 0.3170235217
|
||||
313 0.3167426475
|
||||
314 0.3163718121
|
||||
315 0.3158370493
|
||||
316 0.3155503527
|
||||
317 0.3151236337
|
||||
318 0.3148689295
|
||||
319 0.3146299768
|
||||
320 0.3142772407
|
||||
321 0.3138530784
|
||||
322 0.3135854205
|
||||
323 0.3131214904
|
||||
324 0.3127659838
|
||||
325 0.3122350721
|
||||
326 0.3118475636
|
||||
327 0.3115344437
|
||||
328 0.311237246
|
||||
329 0.3109110889
|
||||
330 0.310639938
|
||||
331 0.3103155862
|
||||
332 0.3098221248
|
||||
333 0.309423914
|
||||
334 0.3091671621
|
||||
335 0.308852111
|
||||
336 0.3084452031
|
||||
337 0.30805284
|
||||
338 0.307790852
|
||||
339 0.3075070726
|
||||
340 0.3070106772
|
||||
341 0.3063522606
|
||||
342 0.306023137
|
||||
343 0.3056081686
|
||||
344 0.3052908972
|
||||
345 0.3050698337
|
||||
346 0.304718801
|
||||
347 0.3043544625
|
||||
348 0.3041033502
|
||||
349 0.3037743316
|
||||
350 0.3034668293
|
||||
351 0.3030885587
|
||||
352 0.3026812327
|
||||
353 0.3021014274
|
||||
354 0.3018628727
|
||||
355 0.3015681515
|
||||
356 0.3012563129
|
||||
357 0.3008425713
|
||||
358 0.3006504824
|
||||
359 0.3002997122
|
||||
360 0.29986022
|
||||
361 0.2994157375
|
||||
362 0.2991488897
|
||||
363 0.2987604674
|
||||
364 0.2984520322
|
||||
365 0.2980086594
|
||||
366 0.2976722806
|
||||
367 0.297418779
|
||||
368 0.2970540834
|
||||
369 0.2968505628
|
||||
370 0.2966096352
|
||||
371 0.2962534879
|
||||
372 0.2956966575
|
||||
373 0.295467724
|
||||
374 0.295198672
|
||||
375 0.2948654216
|
||||
376 0.2944509322
|
||||
377 0.294163659
|
||||
378 0.2938644764
|
||||
379 0.293532816
|
||||
380 0.2932769543
|
||||
381 0.2930012713
|
||||
382 0.2927528101
|
||||
383 0.2924546703
|
||||
384 0.2921348133
|
||||
385 0.2918413938
|
||||
386 0.2914998283
|
||||
387 0.2912741093
|
||||
388 0.2910467504
|
||||
389 0.2908811787
|
||||
390 0.29031764
|
||||
391 0.2900000009
|
||||
392 0.2897507124
|
||||
393 0.2895248451
|
||||
394 0.2892178364
|
||||
395 0.2888956874
|
||||
396 0.2885872177
|
||||
397 0.2883226548
|
||||
398 0.2880616544
|
||||
399 0.2877225749
|
||||
|
@@ -1,401 +0,0 @@
|
||||
iter Passed Remaining
|
||||
0 1 459
|
||||
1 2 459
|
||||
2 3 445
|
||||
3 4 443
|
||||
4 5 441
|
||||
5 6 437
|
||||
6 7 434
|
||||
7 8 435
|
||||
8 9 433
|
||||
9 11 429
|
||||
10 12 429
|
||||
11 13 427
|
||||
12 14 424
|
||||
13 15 421
|
||||
14 16 421
|
||||
15 17 421
|
||||
16 18 419
|
||||
17 19 418
|
||||
18 20 417
|
||||
19 21 414
|
||||
20 22 413
|
||||
21 24 412
|
||||
22 25 410
|
||||
23 26 409
|
||||
24 27 409
|
||||
25 28 409
|
||||
26 29 408
|
||||
27 30 407
|
||||
28 31 407
|
||||
29 33 407
|
||||
30 34 406
|
||||
31 35 406
|
||||
32 36 405
|
||||
33 37 405
|
||||
34 38 404
|
||||
35 39 403
|
||||
36 41 403
|
||||
37 42 402
|
||||
38 43 401
|
||||
39 44 401
|
||||
40 45 399
|
||||
41 46 398
|
||||
42 48 398
|
||||
43 49 397
|
||||
44 50 395
|
||||
45 51 395
|
||||
46 52 394
|
||||
47 53 393
|
||||
48 54 391
|
||||
49 55 390
|
||||
50 56 389
|
||||
51 57 387
|
||||
52 59 387
|
||||
53 60 385
|
||||
54 61 384
|
||||
55 62 382
|
||||
56 63 381
|
||||
57 64 380
|
||||
58 65 378
|
||||
59 66 377
|
||||
60 67 376
|
||||
61 68 374
|
||||
62 69 373
|
||||
63 71 372
|
||||
64 72 371
|
||||
65 73 370
|
||||
66 74 369
|
||||
67 75 368
|
||||
68 76 367
|
||||
69 77 366
|
||||
70 78 364
|
||||
71 79 363
|
||||
72 80 362
|
||||
73 81 361
|
||||
74 83 360
|
||||
75 84 358
|
||||
76 85 357
|
||||
77 86 356
|
||||
78 87 355
|
||||
79 88 354
|
||||
80 89 353
|
||||
81 90 352
|
||||
82 91 351
|
||||
83 93 349
|
||||
84 94 348
|
||||
85 95 347
|
||||
86 96 346
|
||||
87 97 345
|
||||
88 98 344
|
||||
89 99 342
|
||||
90 100 341
|
||||
91 101 340
|
||||
92 102 339
|
||||
93 103 338
|
||||
94 104 336
|
||||
95 105 335
|
||||
96 107 334
|
||||
97 108 333
|
||||
98 109 332
|
||||
99 110 331
|
||||
100 111 330
|
||||
101 112 329
|
||||
102 113 328
|
||||
103 115 327
|
||||
104 116 326
|
||||
105 117 325
|
||||
106 118 324
|
||||
107 119 323
|
||||
108 120 322
|
||||
109 121 321
|
||||
110 122 320
|
||||
111 124 318
|
||||
112 125 317
|
||||
113 126 316
|
||||
114 127 315
|
||||
115 128 314
|
||||
116 129 313
|
||||
117 130 312
|
||||
118 131 311
|
||||
119 132 310
|
||||
120 134 309
|
||||
121 135 307
|
||||
122 136 306
|
||||
123 137 305
|
||||
124 138 304
|
||||
125 139 303
|
||||
126 140 302
|
||||
127 142 301
|
||||
128 143 300
|
||||
129 144 299
|
||||
130 145 298
|
||||
131 146 297
|
||||
132 147 296
|
||||
133 148 295
|
||||
134 149 293
|
||||
135 150 292
|
||||
136 152 291
|
||||
137 153 290
|
||||
138 154 289
|
||||
139 155 288
|
||||
140 156 287
|
||||
141 157 286
|
||||
142 158 285
|
||||
143 159 284
|
||||
144 161 283
|
||||
145 162 282
|
||||
146 163 281
|
||||
147 164 280
|
||||
148 165 279
|
||||
149 166 277
|
||||
150 167 276
|
||||
151 168 275
|
||||
152 170 275
|
||||
153 171 274
|
||||
154 172 273
|
||||
155 173 272
|
||||
156 175 270
|
||||
157 176 269
|
||||
158 177 268
|
||||
159 178 267
|
||||
160 179 266
|
||||
161 180 265
|
||||
162 181 264
|
||||
163 182 263
|
||||
164 183 261
|
||||
165 185 260
|
||||
166 186 259
|
||||
167 187 258
|
||||
168 188 257
|
||||
169 189 256
|
||||
170 190 255
|
||||
171 191 254
|
||||
172 192 253
|
||||
173 193 251
|
||||
174 195 250
|
||||
175 196 249
|
||||
176 197 248
|
||||
177 198 247
|
||||
178 199 246
|
||||
179 200 245
|
||||
180 201 243
|
||||
181 202 242
|
||||
182 203 241
|
||||
183 205 240
|
||||
184 206 239
|
||||
185 207 238
|
||||
186 208 237
|
||||
187 209 236
|
||||
188 210 235
|
||||
189 211 234
|
||||
190 213 233
|
||||
191 214 231
|
||||
192 215 230
|
||||
193 216 229
|
||||
194 217 228
|
||||
195 218 227
|
||||
196 219 226
|
||||
197 220 225
|
||||
198 221 223
|
||||
199 222 222
|
||||
200 224 221
|
||||
201 225 220
|
||||
202 226 219
|
||||
203 227 218
|
||||
204 228 217
|
||||
205 229 216
|
||||
206 230 215
|
||||
207 231 214
|
||||
208 233 213
|
||||
209 234 211
|
||||
210 235 210
|
||||
211 236 209
|
||||
212 237 208
|
||||
213 238 207
|
||||
214 239 206
|
||||
215 240 205
|
||||
216 242 204
|
||||
217 243 202
|
||||
218 244 201
|
||||
219 245 200
|
||||
220 246 199
|
||||
221 247 198
|
||||
222 248 197
|
||||
223 249 196
|
||||
224 251 195
|
||||
225 252 194
|
||||
226 253 193
|
||||
227 254 191
|
||||
228 255 190
|
||||
229 256 189
|
||||
230 257 188
|
||||
231 258 187
|
||||
232 260 186
|
||||
233 261 185
|
||||
234 262 184
|
||||
235 263 183
|
||||
236 264 181
|
||||
237 265 180
|
||||
238 266 179
|
||||
239 267 178
|
||||
240 269 177
|
||||
241 270 176
|
||||
242 271 175
|
||||
243 272 174
|
||||
244 273 173
|
||||
245 274 172
|
||||
246 275 170
|
||||
247 277 169
|
||||
248 278 168
|
||||
249 279 167
|
||||
250 280 166
|
||||
251 281 165
|
||||
252 282 164
|
||||
253 283 163
|
||||
254 285 162
|
||||
255 286 160
|
||||
256 287 159
|
||||
257 288 158
|
||||
258 289 157
|
||||
259 290 156
|
||||
260 291 155
|
||||
261 292 154
|
||||
262 293 152
|
||||
263 294 151
|
||||
264 295 150
|
||||
265 297 149
|
||||
266 298 148
|
||||
267 299 147
|
||||
268 300 146
|
||||
269 301 145
|
||||
270 302 144
|
||||
271 303 142
|
||||
272 304 141
|
||||
273 305 140
|
||||
274 306 139
|
||||
275 308 138
|
||||
276 309 137
|
||||
277 310 136
|
||||
278 311 135
|
||||
279 312 133
|
||||
280 313 132
|
||||
281 314 131
|
||||
282 315 130
|
||||
283 317 129
|
||||
284 318 128
|
||||
285 319 127
|
||||
286 320 126
|
||||
287 321 125
|
||||
288 322 124
|
||||
289 323 122
|
||||
290 325 121
|
||||
291 326 120
|
||||
292 327 119
|
||||
293 328 118
|
||||
294 329 117
|
||||
295 330 116
|
||||
296 332 115
|
||||
297 333 114
|
||||
298 334 112
|
||||
299 335 111
|
||||
300 336 110
|
||||
301 337 109
|
||||
302 338 108
|
||||
303 339 107
|
||||
304 341 106
|
||||
305 342 105
|
||||
306 343 104
|
||||
307 344 102
|
||||
308 345 101
|
||||
309 346 100
|
||||
310 347 99
|
||||
311 349 98
|
||||
312 350 97
|
||||
313 351 96
|
||||
314 352 95
|
||||
315 353 93
|
||||
316 354 92
|
||||
317 355 91
|
||||
318 356 90
|
||||
319 357 89
|
||||
320 358 88
|
||||
321 360 87
|
||||
322 361 86
|
||||
323 362 84
|
||||
324 363 83
|
||||
325 364 82
|
||||
326 365 81
|
||||
327 366 80
|
||||
328 367 79
|
||||
329 368 78
|
||||
330 370 77
|
||||
331 371 76
|
||||
332 372 74
|
||||
333 373 73
|
||||
334 374 72
|
||||
335 375 71
|
||||
336 376 70
|
||||
337 378 69
|
||||
338 379 68
|
||||
339 380 67
|
||||
340 381 65
|
||||
341 382 64
|
||||
342 383 63
|
||||
343 384 62
|
||||
344 385 61
|
||||
345 386 60
|
||||
346 387 59
|
||||
347 389 58
|
||||
348 390 57
|
||||
349 391 55
|
||||
350 392 54
|
||||
351 393 53
|
||||
352 394 52
|
||||
353 395 51
|
||||
354 397 50
|
||||
355 398 49
|
||||
356 399 48
|
||||
357 400 46
|
||||
358 401 45
|
||||
359 402 44
|
||||
360 403 43
|
||||
361 404 42
|
||||
362 406 41
|
||||
363 407 40
|
||||
364 408 39
|
||||
365 409 38
|
||||
366 410 36
|
||||
367 411 35
|
||||
368 412 34
|
||||
369 413 33
|
||||
370 414 32
|
||||
371 415 31
|
||||
372 417 30
|
||||
373 418 29
|
||||
374 419 27
|
||||
375 420 26
|
||||
376 421 25
|
||||
377 422 24
|
||||
378 423 23
|
||||
379 424 22
|
||||
380 425 21
|
||||
381 427 20
|
||||
382 428 19
|
||||
383 429 17
|
||||
384 430 16
|
||||
385 431 15
|
||||
386 432 14
|
||||
387 433 13
|
||||
388 434 12
|
||||
389 435 11
|
||||
390 437 10
|
||||
391 438 8
|
||||
392 439 7
|
||||
393 440 6
|
||||
394 441 5
|
||||
395 442 4
|
||||
396 443 3
|
||||
397 444 2
|
||||
398 446 1
|
||||
399 447 0
|
||||
|
@@ -1,181 +0,0 @@
|
||||
# Design notes — why the preprocessing modules do what they do
|
||||
|
||||
Reference for the methodology behind `src/`. The code carries short contract
|
||||
docstrings; the reasoning lives here. Results and model performance are in the
|
||||
top-level [README.md](../README.md); the production contract is in
|
||||
[`production/classifier_symmetric/README.md`](../production/classifier_symmetric/README.md).
|
||||
|
||||
---
|
||||
|
||||
## `config.py` — why whole column families are excluded
|
||||
|
||||
The `hist_*_FN[+-]k`, `*_before_founding` and `*_after_founding` columns are
|
||||
computed relative to a founding event and are **identically zero for every
|
||||
non-founder row** in `datasets_complete`. In RQ1 (full-profile founder vs.
|
||||
non-founder) a model would separate the classes on that artifact rather than on
|
||||
signal, so they are excluded from `RQ1_FEATURE_COLUMNS`.
|
||||
|
||||
`RQ1_PREFOUNDING_PAIRS` handles the opposite direction. For founders, lifetime
|
||||
totals include **post**-founding activity (e.g. continuing to publish part-time
|
||||
after founding) — a reverse-causation confound that lets a model key off a
|
||||
downstream *effect* of founding. Non-founders have no equivalent issue: their
|
||||
full total is inherently "pre-founding". For the four metrics where a validated
|
||||
`_before_founding` split exists, `data._apply_prefounding_equivalent` swaps it in.
|
||||
|
||||
## `data.py` — leakage-safe loading for RQ1 and RQ2
|
||||
|
||||
**RQ1** reads `evaluation/datasets_complete`, drops identifier and leaky columns
|
||||
(`config.RQ1_DROP_COLUMNS`) and keeps the remaining full-career aggregates.
|
||||
|
||||
**RQ2** ("founds within N years") reads the curated 13-column half-profile
|
||||
datasets (`datasets_halfprofiles_offset{1,2,3}`) as the positive class at each
|
||||
horizon, paired with non-founders from `datasets_complete` on the same curated
|
||||
columns, which are legitimate and non-degenerate for non-founders too.
|
||||
|
||||
Non-founders are split 70/30 per institution **once** (fixed `random_state`)
|
||||
into a training pool (offsets 1–3) and a holdout pool reserved exclusively for
|
||||
the offset-3/5 horizon-validation sets, so no individual is ever seen in both
|
||||
training and horizon-generalization testing.
|
||||
|
||||
## `outliers.py` — two-stage multivariate outlier detection
|
||||
|
||||
Replaces the original `publications < 1000` / `patents < 1000` guard inherited
|
||||
from the source notebooks. That guard does remove real rows (677 of them), but
|
||||
the underlying problem is worse than a long tail: several of the most extreme
|
||||
rows — "Hui Zhang" with 20,703 publications and 49,398 patents, "David Smith"
|
||||
with 16,713 publications — are almost certainly **common-name collisions**.
|
||||
Dimensions' name-based researcher matching merges dozens of distinct real people
|
||||
who share a common name into one aggregated profile; these are not genuinely
|
||||
hyper-prolific individuals.
|
||||
|
||||
A single hand-picked threshold on one or two columns cannot reliably separate
|
||||
"very productive but real" from "impossible amalgamation of several people", so
|
||||
outlier handling is two-staged:
|
||||
|
||||
1. A generous, documented **sanity ceiling** — any individual researcher with
|
||||
more than 5,000 lifetime publications or patents is implausible even for
|
||||
extreme large-collaboration physics — to drop flagrant collisions outright.
|
||||
2. An **Isolation Forest** fit in log-space on the remaining rows across the
|
||||
full numeric feature set (not just publications/patents), to catch subtler
|
||||
multivariate anomalies — e.g. an internally inconsistent feature combination
|
||||
that no single-column cutoff would flag.
|
||||
|
||||
## `yearly_counts.py` — per-person, per-year activity from the raw exports
|
||||
|
||||
The raw files in `dimensions_data/` are per-person record lists: each row is one
|
||||
(record × tracked person) pair, keyed by `author_people`. They cover the
|
||||
**founder cohort only** — non-founders were extracted live from the Dimensions
|
||||
API, their per-record data was never saved, and the API key has since expired.
|
||||
|
||||
These exact yearly counts are used two ways:
|
||||
|
||||
1. Exact truncation of founder features at the founding year, replacing the
|
||||
coarser `*_before_founding` splits.
|
||||
2. Fitting the empirical career-trajectory curves in `career_curves.py`, which
|
||||
calibrate the truncation of non-founder lifetime totals at a pseudo-founding
|
||||
year — validated against the founders' exact counts, where both are known.
|
||||
|
||||
**Grants cap.** The `grants` feature counts grant IDs acknowledged on a person's
|
||||
publications, so a single consortium paper can contribute 100+ "grants". The
|
||||
module also emits a capped variant crediting at most `GRANTS_PER_PAPER_CAP`
|
||||
distinct grant IDs per publication, mirroring the hyperauthorship cap in the
|
||||
production profiling module. The empirical distribution of grants per linked
|
||||
paper is p50 = 3, p90 ≈ 6–14 depending on institution, with a consortium tail
|
||||
reaching 409. The cap sits above ordinary multi-grant papers and below the
|
||||
consortium artifacts (~100+/paper) that inflated `grants` roughly 100×.
|
||||
|
||||
## `career_curves.py` — index-date truncation of lifetime totals
|
||||
|
||||
The symmetric redesign needs every person's activity counts **as of an index
|
||||
year** (real founding year for founders, sampled pseudo-founding year for
|
||||
non-founders). Exact per-year records exist only for founders; non-founders have
|
||||
lifetime totals plus first/last activity years.
|
||||
|
||||
We therefore estimate, from the founders' raw trajectories, the average
|
||||
cumulative-share curve
|
||||
|
||||
```
|
||||
F(u) = expected fraction of lifetime output accumulated by career fraction u
|
||||
u = (index_year - first_year) / (last_year + 1 - first_year)
|
||||
```
|
||||
|
||||
separately per activity type (pubs / patents / grants) and career-length
|
||||
stratum, and truncate totals as `total_at_index = total * F(u)`.
|
||||
|
||||
**Critical symmetry rule:** this construction is applied to **both** classes.
|
||||
Founders' exact counts are used only to (a) fit the curves and (b) quantify the
|
||||
approximation error against ground truth (`validate_on_founders`, log-space
|
||||
R² 0.89–0.94). If founders got exact counts while non-founders got smoothed
|
||||
ones, the residual noise texture alone would separate the classes — the exact
|
||||
artifact this redesign removes.
|
||||
|
||||
## `symmetric.py` — the landmark design
|
||||
|
||||
Replaces the asymmetric RQ1/RQ2 preprocessing in `data.py`, where founders'
|
||||
lifetime totals were truncated at their founding year while non-founders kept
|
||||
full-career totals. That made observation-window length a function of the label:
|
||||
the classifier's dominant feature (`publications`) partly encoded the truncation
|
||||
rather than productivity — probability of founding fell monotonically with
|
||||
output, and the 0.918 → 0.976 ROC-AUC "improvement" of the asymmetric fix was a
|
||||
class-separability artifact.
|
||||
|
||||
1. **Index year.** Founders get their cleaned founding year; non-founders a
|
||||
pseudo-founding year sampled from the founders' empirical
|
||||
career-age-at-founding distribution, matched on career-start cohort
|
||||
(landmark / matched index-date design, cf. immortal-time bias).
|
||||
2. **Identical feature construction for both classes**, as deterministic
|
||||
functions of (lifetime totals, first/last activity years, index year) via
|
||||
`career_curves.py`. Founders' exact per-year records are used only to fit and
|
||||
validate those curves — never as a founder-only feature pathway.
|
||||
3. **Citation features excluded** (h-index, i10, g-index, citation sums/means):
|
||||
citations cannot be historicized to the index year for either class, and
|
||||
their full-career values are window-contaminated.
|
||||
4. **`grants` de-inflated** with the per-paper cap from `yearly_counts.py`,
|
||||
applied through a ratio curve so both classes go through the same mapping.
|
||||
|
||||
Two further filters, both applied to **both** classes:
|
||||
|
||||
- **Population definition.** The coach-facing tool scores academics, so the
|
||||
modelled population requires a minimal academic record at the index date
|
||||
(≥ 4 publications). Without it, a sampling-frame clash dominates the
|
||||
thin-profile region: founders come from company databases (people with 1–3
|
||||
lifetime papers included), non-founders from institutional researcher lists
|
||||
(thin profiles underrepresented), making "long career + tiny record" read as
|
||||
65–72% founder. Those people are out of scope for the product, not evidence.
|
||||
- **Plausibility filter.** Profiles with a > 60-year publishing span or a
|
||||
sustained lifetime rate above 25 papers/year are name-collision aggregates
|
||||
(e.g. an "M Nakamura" spanning 1919–2023 with 28k papers). These concentrate
|
||||
in the non-founder class — matched by name alone, vs company + name for
|
||||
founders — so left in they asymmetrically inflate non-founder output.
|
||||
|
||||
## `sequence_data.py` — founder-only sequence dataset
|
||||
|
||||
Task: predict career-relative founding timing from pre-founding activity, using
|
||||
the `hist_{pub,pat,grant}_FN-1..FN-20` columns (chronological yearly counts in
|
||||
the 20 years strictly before founding).
|
||||
|
||||
**Non-founders are not included.** Their equivalent columns are computed with
|
||||
`founded_year` hardcoded to literal year 0 in
|
||||
`extraction/non_founders_scripts.ipynb` (`generate_history(..., nonstartup=True)`
|
||||
forces `founded_year = 0`), so they are all-zero placeholders anchored at
|
||||
1 BCE/1 CE — not real "N years before some reference point" sequences. There is
|
||||
no valid apples-to-apples non-founder sequence in the extracted data; see
|
||||
`experiments/run_sequence_reconstruction_spike.py` for an attempt to build one
|
||||
from the raw per-paper/per-patent data instead.
|
||||
|
||||
**Target:** `founding_age = founded_on (year) - first_publication_year`, i.e.
|
||||
how many years into their publishing career a founder started their company.
|
||||
Only well-posed when `founding_age <= WINDOW` (20): the input window is a fixed
|
||||
20-year lookback, so a longer real pre-founding career would look identical to a
|
||||
≥ 20-year case regardless of the true value. This is a structural
|
||||
right-censoring limit of the fixed window, not a modeling failure, so those rows
|
||||
are excluded from the regression task by default and the excluded count is
|
||||
always reported.
|
||||
|
||||
## `run_rq1_robustness.py` — `scale_pos_weight` under StratifiedKFold
|
||||
|
||||
StratifiedKFold keeps each fold's class ratio approximately equal to the
|
||||
full-data ratio, so a single overall `scale_pos_weight` is a good per-fold
|
||||
approximation for xgboost — which, unlike RF/LightGBM's
|
||||
`class_weight="balanced"`, needs it set explicitly to correct for the ~37%
|
||||
founder rate.
|
||||
@@ -1,149 +0,0 @@
|
||||
name: potential
|
||||
channels:
|
||||
- conda-forge
|
||||
- defaults
|
||||
- https://repo.anaconda.com/pkgs/main
|
||||
- https://repo.anaconda.com/pkgs/r
|
||||
dependencies:
|
||||
- _openmp_mutex=4.5
|
||||
- brotli=1.2.0
|
||||
- brotli-bin=1.2.0
|
||||
- bzip2=1.0.8
|
||||
- ca-certificates=2026.7.22
|
||||
- cairo=1.18.4
|
||||
- contourpy=1.3.3
|
||||
- cpython=3.11.15
|
||||
- cycler=0.12.1
|
||||
- filelock=3.32.2
|
||||
- fmt=12.1.0
|
||||
- font-ttf-dejavu-sans-mono=2.37
|
||||
- font-ttf-inconsolata=3.000
|
||||
- font-ttf-source-code-pro=2.038
|
||||
- font-ttf-ubuntu=0.83
|
||||
- fontconfig=2.18.2
|
||||
- fonts-conda-ecosystem=1
|
||||
- fonts-conda-forge=1
|
||||
- fonttools=4.63.0
|
||||
- freetype=2.14.3
|
||||
- fribidi=1.0.16
|
||||
- fsspec=2026.7.0
|
||||
- gmp=6.3.0
|
||||
- gmpy2=2.3.0
|
||||
- graphite2=1.3.15
|
||||
- icu=78.3
|
||||
- jinja2=3.1.6
|
||||
- joblib=1.5.3
|
||||
- kiwisolver=1.5.0
|
||||
- lcms2=2.19.1
|
||||
- lerc=4.2.0
|
||||
- libabseil=20260526.0
|
||||
- libblas=3.11.0
|
||||
- libbrotlicommon=1.2.0
|
||||
- libbrotlidec=1.2.0
|
||||
- libbrotlienc=1.2.0
|
||||
- libcblas=3.11.0
|
||||
- libcxx=22.1.8
|
||||
- libdeflate=1.25
|
||||
- libexpat=2.8.1
|
||||
- libffi=3.5.2
|
||||
- libfreetype=2.14.3
|
||||
- libfreetype6=2.14.3
|
||||
- libgcc=16.1.0
|
||||
- libgfortran=16.1.0
|
||||
- libgfortran5=16.1.0
|
||||
- libglib=2.88.3
|
||||
- libharfbuzz=14.3.0
|
||||
- libiconv=1.18
|
||||
- libintl=0.25.1
|
||||
- libjpeg-turbo=3.2.0
|
||||
- liblapack=3.11.0
|
||||
- liblzma=5.8.3
|
||||
- libopenblas=0.3.33
|
||||
- libpng=1.6.58
|
||||
- libprotobuf=7.35.1
|
||||
- libraqm=0.11.0
|
||||
- libsqlite=3.53.4
|
||||
- libtiff=4.7.2
|
||||
- libtorch=2.13.0
|
||||
- libuv=1.52.1
|
||||
- libwebp-base=1.6.0
|
||||
- libxcb=1.17.0
|
||||
- libzlib=1.3.2
|
||||
- llvm-openmp=22.1.8
|
||||
- markupsafe=3.0.3
|
||||
- matplotlib=3.11.1
|
||||
- matplotlib-base=3.11.1
|
||||
- mpc=1.4.0
|
||||
- mpfr=4.2.2
|
||||
- munkres=1.1.4
|
||||
- narwhals=2.24.0
|
||||
- ncurses=6.6
|
||||
- networkx=3.6.1
|
||||
- nomkl=1.0
|
||||
- numpy=2.4.6
|
||||
- onednn=3.12
|
||||
- openjpeg=2.5.4
|
||||
- openssl=3.6.3
|
||||
- optree=0.19.1
|
||||
- packaging=26.2
|
||||
- patsy=1.0.2
|
||||
- pcre2=10.47
|
||||
- pillow=12.3.0
|
||||
- pip=26.2
|
||||
- pixman=0.46.4
|
||||
- pthread-stubs=0.4
|
||||
- pybind11=3.0.3
|
||||
- pybind11-abi=11
|
||||
- pybind11-global=3.0.3
|
||||
- pyparsing=3.3.2
|
||||
- python=3.11.15
|
||||
- python-dateutil=2.9.0.post0
|
||||
- python_abi=3.11
|
||||
- pytorch=2.13.0
|
||||
- qhull=2020.2
|
||||
- readline=8.3
|
||||
- scikit-learn=1.9.0
|
||||
- scipy=1.17.1
|
||||
- seaborn=0.13.2
|
||||
- seaborn-base=0.13.2
|
||||
- setuptools=81.0.0
|
||||
- six=1.17.0
|
||||
- sleef=3.9.0
|
||||
- statsmodels=0.14.6
|
||||
- sympy=1.14.0
|
||||
- threadpoolctl=3.6.0
|
||||
- tk=8.6.13
|
||||
- tornado=6.5.7
|
||||
- tqdm=4.70.0
|
||||
- typing-extensions=4.16.0
|
||||
- typing_extensions=4.16.0
|
||||
- unicodedata2=17.0.1
|
||||
- wheel=0.47.0
|
||||
- xorg-libxau=1.0.12
|
||||
- xorg-libxdmcp=1.1.5
|
||||
- zlib-ng=2.3.3
|
||||
- zstd=1.5.7
|
||||
- pip:
|
||||
- autograd==1.9.1
|
||||
- autograd-gamma==0.5.0
|
||||
- catboost==1.2.10
|
||||
- cloudpickle==3.1.2
|
||||
- formulaic==1.2.2
|
||||
- graphviz==0.21
|
||||
- imbalanced-learn==0.14.2
|
||||
- interface-meta==2.0.1
|
||||
- lifelines==0.30.3
|
||||
- lightgbm==4.7.0
|
||||
- llvmlite==0.48.0
|
||||
- mpmath==1.3.0
|
||||
- numba==0.66.0
|
||||
- pandas==2.3.3
|
||||
- plotly==6.9.0
|
||||
- pytz==2026.3.post1
|
||||
- shap==0.51.0
|
||||
- sklearn-compat==0.1.6
|
||||
- slicer==0.0.8
|
||||
- tabulate==0.10.0
|
||||
- tzdata==2026.3
|
||||
- wrapt==2.3.0
|
||||
- xgboost==3.2.0
|
||||
@@ -1,255 +0,0 @@
|
||||
# Founder-Potential Classifier — Production Guide
|
||||
|
||||
Predicts whether a researcher will found a company ("founder" vs. "non-founder")
|
||||
from their **full career profile** (publications, patents, grants, affiliations).
|
||||
This is the RQ1 model from the research pipeline, re-packaged and validated for
|
||||
an OpenAlex + patents + grants production data source.
|
||||
|
||||
## 1. Which two models, and why
|
||||
|
||||
Ranked empirically on the actual production feature set (87 columns — see
|
||||
§3), by PR-AUC on a held-out 20% stratified split (`validated_holdout_metrics.csv`):
|
||||
|
||||
| rank | model | roc_auc | pr_auc | mcc | f1 | notes |
|
||||
|------|----------------------|---------|--------|-------|-------|-------|
|
||||
| 1 | **lightgbm** | 0.9764 | 0.9681 | 0.848 | 0.903 | single model, 1.3 MB, fastest |
|
||||
| 2 | **stacking_ensemble**| 0.9748 | 0.9657 | 0.846 | 0.903 | RF+XGBoost+LightGBM blended by a logistic meta-learner, 29 MB, ~3x slower |
|
||||
| 3 | xgboost | 0.9728 | 0.9640 | 0.843 | 0.900 | close 3rd, not shipped |
|
||||
| 4 | catboost | 0.9710 | 0.9616 | 0.834 | 0.894 | not shipped |
|
||||
|
||||
`lightgbm` and `stacking_ensemble` are shipped in `models/`. They are within
|
||||
noise of each other (Δpr_auc = 0.002); `lightgbm` is recommended as the default
|
||||
for a production system (simpler, smaller, faster, marginally best), with
|
||||
`stacking_ensemble` as a fallback/cross-check if you want a second opinion or
|
||||
slightly better recall (0.905 vs. 0.890).
|
||||
|
||||
## 2. Files
|
||||
|
||||
```
|
||||
production/classifier/
|
||||
founder_classifier.py <- self-contained wrapper (pandas/numpy/joblib only)
|
||||
models/
|
||||
lightgbm.joblib <- recommended default
|
||||
stacking_ensemble.joblib <- alternative / second opinion
|
||||
feature_importance_lightgbm.csv
|
||||
feature_importance_stacking_ensemble.csv
|
||||
validated_holdout_metrics.csv <- honest held-out metrics for every candidate model
|
||||
manifest.json
|
||||
export_classifier.py <- reproducible export/training script
|
||||
```
|
||||
|
||||
Each `.joblib` is a single self-contained bundle: `{model, feature_columns,
|
||||
numeric_columns, log_columns, research_area_columns, research_area_categories,
|
||||
label_meaning}`. You only need `founder_classifier.py` + one `.joblib` file to
|
||||
run predictions — no dependency on the rest of this repository.
|
||||
|
||||
## 3. OpenAlex / production data compatibility
|
||||
|
||||
Your data comes from OpenAlex (publications + author metrics) with patents and
|
||||
grants matched separately to OpenAlex author IDs. Two adjustments were made
|
||||
relative to the original research pipeline, **both validated empirically, no
|
||||
other change to the model was needed**:
|
||||
|
||||
### 3.1 Institution one-hot dropped
|
||||
|
||||
The research dataset one-hot-encodes 8 training institutions. A model trained
|
||||
that way cannot be meaningfully applied to a 9th, unseen institution (its
|
||||
one-hot vector would be all zeros — out of distribution). This production
|
||||
model was trained **without** institution one-hot at all, so it works for any
|
||||
institution, including yours. Cost: ROC-AUC drops from ~0.976 to ~0.95 in a
|
||||
leave-one-institution-out test (see `experiments/README.md` §RQ1) — a modest,
|
||||
worthwhile trade for portability.
|
||||
|
||||
### 3.2 Four Dimensions-specific columns dropped
|
||||
|
||||
| column | what it needs | why it's likely unavailable to you |
|
||||
|---|---|---|
|
||||
| `pat_citation_mean`, `pat_citation_sum` | citation counts **to** each patent | requires a patent source that tracks patent-citing-patent counts (e.g. USPTO/PatentsView citation graph); a simple OpenAlex-author-matched patent list usually won't have this |
|
||||
| `linked_patents_to_publications` | patents that **cite the person's own papers** (non-patent-literature citations) | requires patent-to-paper citation linkage, which most patent sources don't expose |
|
||||
| `grant_innovation_impact` | count of patents **linked to a specific grant** the person received | requires grant-to-patent linkage, on top of grant-to-person matching |
|
||||
|
||||
These were the exact "things we don't have" flagged as a concern. An ablation
|
||||
(same data, same models, same split, only these 4 of 87 columns removed)
|
||||
showed the difference is within noise:
|
||||
|
||||
| feature set | model | roc_auc | pr_auc | mcc |
|
||||
|---|---|---|---|---|
|
||||
| full (includes the 4 columns) | lightgbm | 0.9763 | 0.9685 | 0.8483 |
|
||||
| **without the 4 columns** | lightgbm | 0.9765 | 0.9689 | 0.8514 |
|
||||
| full (includes the 4 columns) | xgboost | 0.9744 | 0.9666 | 0.8426 |
|
||||
| **without the 4 columns** | xgboost | 0.9741 | 0.9657 | 0.8437 |
|
||||
|
||||
Performance doesn't degrade (if anything, it's marginally better without
|
||||
them — consistent with their near-zero permutation importance, see §6). **No
|
||||
architecture/feature-engineering change was made** beyond simply not including
|
||||
these 4 columns — per "if the model can function without it, don't adjust the
|
||||
model," this is confirmed and no further adaptation was necessary.
|
||||
|
||||
### 3.3 Research-area categories
|
||||
|
||||
`publication_research_area`, `patent_research_area`, `grant_research_area` were
|
||||
trained on the first 2 characters of Dimensions' FOR classification codes
|
||||
(e.g. `"3202 Clinical Sciences"` → `"32"`). If your OpenAlex pipeline classifies
|
||||
research area using OpenAlex Topics/Fields/Domains instead, the exact string
|
||||
values will differ. You have two options:
|
||||
1. **Do nothing.** Pass whatever string/code you have; unrecognized values
|
||||
fall into an all-zero ("unknown") one-hot block for that column, which
|
||||
tree models handle gracefully — you just lose the (modest, ~1-2% combined
|
||||
importance, see §6) signal those columns carry.
|
||||
2. **Map your OpenAlex field/domain names to the 2-digit codes** this model
|
||||
was trained on for full signal. The 21 broad codes used are Dimensions
|
||||
FOR 2-digit divisions (30=Agriculture, 31=Biological Sciences, 32=Biomedical
|
||||
and Clinical Sciences, 33=Built Environment and Design, 34=Chemical
|
||||
Sciences, 35=Commerce/Management/Tourism/Services, 36=Creative Arts and
|
||||
Writing, 37=Earth Sciences, 38=Economics, 39=Education, 40=Engineering,
|
||||
41=Environmental Sciences, 42=Health Sciences, 43=History/Heritage/
|
||||
Archaeology, 44=Human Society, 46=Information and Computing Sciences,
|
||||
47=Language/Communication/Culture, 48=Law and Legal Studies,
|
||||
49=Mathematical Sciences, 50=Philosophy and Religious Studies,
|
||||
51=Physical Sciences, 52=Psychology). `"n."` = unknown/not classified.
|
||||
|
||||
Institution and research-area handling aside, **h-index and i10-index are
|
||||
natively provided by OpenAlex** (`summary_stats.h_index` /
|
||||
`summary_stats.i10_index` on the Author object) — you do not need to compute
|
||||
them yourself, despite them being "calculable."
|
||||
|
||||
## 4. Input schema
|
||||
|
||||
Pass a plain dict (or list of dicts for batch) with any subset of these keys —
|
||||
missing numeric keys default to 0, missing categorical keys default to
|
||||
"unknown". **Fields with no natural zero (the year fields, and any field where
|
||||
"0" would be misleading) should always be supplied from real data** — see §7
|
||||
caveats.
|
||||
|
||||
| field | type | description | source |
|
||||
|---|---|---|---|
|
||||
| `h-index` | int | author h-index | OpenAlex `summary_stats.h_index` (native) |
|
||||
| `i10-index` | int | author i10-index | OpenAlex `summary_stats.i10_index` (native) |
|
||||
| `publications` | int | total publication count | OpenAlex `works_count`, or count of that author's works |
|
||||
| `pub_citation_mean` | float | mean citations per publication | mean of `cited_by_count` across the author's works |
|
||||
| `pub_citation_sum` | float | total citations across publications | OpenAlex Author `cited_by_count` (native), or sum of works' `cited_by_count` |
|
||||
| `first_publication_year` | int | year of first publication | min `publication_year` across works |
|
||||
| `last_publication_year` | int | year of most recent publication | max `publication_year` across works |
|
||||
| `patents` | int | total patent count | your patent-matching pipeline |
|
||||
| `first_patent_year` | int | year of first patent | your patent-matching pipeline |
|
||||
| `last_patent_year` | int | year of most recent patent | your patent-matching pipeline |
|
||||
| `grants` | int | total grants/awards count | your grant-matching pipeline (or OpenAlex `awards` on works) |
|
||||
| `first_grant_year` | int | year of first grant | your grant-matching pipeline |
|
||||
| `last_grant_year` | int | year of most recent grant | your grant-matching pipeline |
|
||||
| `affiliations` | int | count of distinct institutional affiliations | OpenAlex Author `affiliations` (native) |
|
||||
| `activities_total` | int | publications + patents + grants | computed (sum) |
|
||||
| `g-index` | int | g-index (largest g s.t. top-g works have ≥ g² combined citations) | computed from per-work `cited_by_count` — see §5 |
|
||||
| `industry_collab_papers` | int | count of publications co-authored with a company-type institution | OpenAlex works' `authorships.institutions.type == "company"` |
|
||||
| `grant_research_impact` | int | count of publications linked to a grant the person received | OpenAlex works' `awards` field, or your grant-to-publication matching |
|
||||
| `publication_research_area` | str | broad research-area code of publications | see §3.3 |
|
||||
| `patent_research_area` | str | broad research-area code of patents | see §3.3 |
|
||||
| `grant_research_area` | str | broad research-area code of grants | see §3.3 |
|
||||
|
||||
Do **not** pass `institution` — it is not used by this model (see §3.1).
|
||||
|
||||
### 5. Computing g-index from OpenAlex
|
||||
|
||||
OpenAlex has no native g-index field. Compute it directly from a list of the
|
||||
person's per-work citation counts (`cited_by_count`), sorted descending:
|
||||
|
||||
```python
|
||||
def g_index(citation_counts: list[int]) -> int:
|
||||
counts = sorted(citation_counts, reverse=True)
|
||||
g = 0
|
||||
cumulative = 0
|
||||
for i, c in enumerate(counts, start=1):
|
||||
cumulative += c
|
||||
if cumulative >= i * i:
|
||||
g = i
|
||||
else:
|
||||
break
|
||||
return g
|
||||
```
|
||||
|
||||
## 6. Output format
|
||||
|
||||
```python
|
||||
clf.predict_one({...})
|
||||
# {'prediction': 1, 'probability_founder': 0.87, 'label': 'founder', 'model': 'lightgbm'}
|
||||
```
|
||||
|
||||
- `prediction`: 0 (non-founder) or 1 (founder), thresholded at `probability_founder >= 0.5`
|
||||
- `probability_founder`: calibrated-ish probability in [0, 1] from `predict_proba`
|
||||
- `label`: human-readable string version of `prediction`
|
||||
|
||||
`clf.predict([...])` (batch) returns a `pandas.DataFrame` with `prediction` and
|
||||
`probability_founder` columns, one row per input record, in input order.
|
||||
|
||||
## 7. Usage example
|
||||
|
||||
```python
|
||||
from founder_classifier import FounderClassifier
|
||||
|
||||
clf = FounderClassifier.load("models/lightgbm.joblib")
|
||||
|
||||
result = clf.predict_one({
|
||||
"h-index": 12, "i10-index": 15, "publications": 40,
|
||||
"pub_citation_mean": 22.5, "pub_citation_sum": 900,
|
||||
"first_publication_year": 2005, "last_publication_year": 2021,
|
||||
"patents": 2, "first_patent_year": 2015, "last_patent_year": 2018,
|
||||
"grants": 3, "first_grant_year": 2010, "last_grant_year": 2019,
|
||||
"affiliations": 2, "activities_total": 45, "g-index": 10,
|
||||
"industry_collab_papers": 4, "grant_research_impact": 5,
|
||||
"publication_research_area": "32", "patent_research_area": "32",
|
||||
"grant_research_area": "32",
|
||||
})
|
||||
print(result)
|
||||
# {'prediction': 1, 'probability_founder': 0.957, 'label': 'founder', 'model': 'lightgbm'}
|
||||
```
|
||||
|
||||
For a second opinion, load `stacking_ensemble.joblib` the same way and compare.
|
||||
|
||||
## 8. Features that affect the classification most
|
||||
|
||||
Permutation importance (mean drop in PR-AUC when a feature is shuffled) on the
|
||||
held-out test split, for both shipped models:
|
||||
|
||||
| feature | lightgbm | stacking_ensemble | OpenAlex availability |
|
||||
|---|---|---|---|
|
||||
| `publications` | **0.494** (dominant) | **0.323** (dominant) | native |
|
||||
| `pub_citation_sum` | 0.100 | 0.069 | computed from works |
|
||||
| `last_patent_year` | 0.089 | 0.081 | your patent pipeline |
|
||||
| `pub_citation_mean` | 0.058 | 0.042 | computed from works |
|
||||
| `i10-index` | 0.058 | 0.035 | native |
|
||||
| `g-index` | 0.039 | 0.035 | computed (§5) |
|
||||
| `activities_total` | 0.023 | 0.021 | computed |
|
||||
| `grants` | 0.023 | 0.019 | your grant pipeline |
|
||||
| `first_publication_year` | 0.016 | 0.015 | native |
|
||||
| `last_publication_year` | 0.010 | — | native |
|
||||
|
||||
**`publications` alone dwarfs every other feature** — by a wide margin, the
|
||||
single most important signal is simply how many papers someone has published.
|
||||
Citation-based signals (`pub_citation_sum`/`mean`, `i10-index`, `g-index`) are
|
||||
a clear second tier. Patent/grant *counts* matter far less than publication
|
||||
volume, and the timing feature `last_patent_year` is surprisingly informative
|
||||
(likely a proxy for "still recently active in applied/patentable work" close
|
||||
to the founding decision). Research-area and institution-adjacent signals are
|
||||
minor (each individual one-hot column contributes < 0.5% importance). Full
|
||||
per-model tables: `feature_importance_lightgbm.csv`,
|
||||
`feature_importance_stacking_ensemble.csv`.
|
||||
|
||||
## 9. Caveats
|
||||
|
||||
- **This is a full-career-profile model** (RQ1): it answers "does this
|
||||
person's overall profile look like a founder's?", not "will they found a
|
||||
company in the next N years?" — for the latter, see the sequence models
|
||||
(`../sequence/README.md`).
|
||||
- **Out-of-distribution inputs are not guarded against.** A record with almost
|
||||
all fields missing/zero is nonsensical (every real researcher has *some*
|
||||
publications) and can produce an unreliable, overconfident prediction —
|
||||
this was observed directly (an all-empty dict predicts "founder" at 99.7%
|
||||
confidence, an artifact of the model extrapolating into a region with no
|
||||
real training examples, not a meaningful result). Only call this model with
|
||||
real profile data for someone who has at least some publication history.
|
||||
- **Retraining on your own labeled data** (once you have enough founder/
|
||||
non-founder examples from your own institution) will likely outperform this
|
||||
model, especially for the research-area categorical signal (§3.3). This
|
||||
model is a strong starting point / cold-start solution before you have your
|
||||
own labels.
|
||||
- Reproduce or retrain via `export_classifier.py` (depends on the full
|
||||
`experiments/src` research package + `evaluation/datasets_complete`).
|
||||
@@ -1,144 +0,0 @@
|
||||
"""Export the two best RQ1 classifiers as standalone production artifacts,
|
||||
adapted for an OpenAlex + patents + grants data pipeline.
|
||||
|
||||
Two adaptations vs `src/data.py::build_rq1_matrix`: the `institution` one-hot is
|
||||
dropped (a model trained on 8 one-hots cannot be applied to a 9th, unseen
|
||||
institution), and four Dimensions-specific columns are dropped as unavailable
|
||||
when patents are matched to OpenAlex authors. Measured cost of each: README.md
|
||||
in this directory, "OpenAlex / production data compatibility".
|
||||
|
||||
Run: conda run -n potential python production/classifier/export_classifier.py
|
||||
(from the experiments/ directory)
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import joblib
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from sklearn.inspection import permutation_importance
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
from src import config, data, evaluate, models, splits # noqa: E402
|
||||
|
||||
OUT_DIR = Path(__file__).resolve().parent
|
||||
MODELS_DIR = OUT_DIR / "models"
|
||||
MODELS_DIR.mkdir(exist_ok=True)
|
||||
|
||||
# Columns dropped for OpenAlex/production compatibility -- see module docstring.
|
||||
UNAVAILABLE_COLUMNS = [
|
||||
"pat_citation_mean",
|
||||
"pat_citation_sum",
|
||||
"linked_patents_to_publications",
|
||||
"grant_innovation_impact",
|
||||
]
|
||||
|
||||
RESEARCH_AREA_COLUMNS = ["publication_research_area", "patent_research_area", "grant_research_area"]
|
||||
|
||||
# The two models to ship, chosen empirically (see rank_production_models below).
|
||||
SHIP_MODELS = ["lightgbm", "stacking_ensemble"]
|
||||
|
||||
|
||||
def build_production_matrix(df):
|
||||
"""Same as data.build_rq1_matrix(include_institution=False) minus the four
|
||||
OpenAlex/production-unavailable columns."""
|
||||
X, y, groups = data.build_rq1_matrix(df, include_institution=False)
|
||||
X = X.drop(columns=UNAVAILABLE_COLUMNS)
|
||||
return X, y, groups
|
||||
|
||||
|
||||
def rank_and_validate(X, y):
|
||||
"""Fit every candidate on a held-out split so we get honest metrics + a
|
||||
permutation importance ranking for the *actual shipped* feature set."""
|
||||
X_train, X_test, y_train, y_test = splits.stratified_holdout(X, y, test_size=0.2)
|
||||
spw = (y_train == 0).sum() / (y_train == 1).sum()
|
||||
candidates = {
|
||||
**models.advanced_models(scale_pos_weight=spw),
|
||||
"stacking_ensemble": models.stacking_model(scale_pos_weight=spw),
|
||||
}
|
||||
rows, fitted = [], {}
|
||||
for name, model in candidates.items():
|
||||
model, metrics, pred, proba = evaluate.fit_and_evaluate(model, X_train, y_train, X_test, y_test)
|
||||
rows.append({"model": name, **metrics})
|
||||
fitted[name] = model
|
||||
table = evaluate.results_table(rows, sort_by="pr_auc")
|
||||
print("Validated performance (held-out 20% split, production feature set):")
|
||||
print(table[["accuracy", "precision", "recall", "f1", "roc_auc", "pr_auc", "mcc"]])
|
||||
table.to_csv(OUT_DIR / "validated_holdout_metrics.csv")
|
||||
|
||||
# Permutation importance for each shipped model on the held-out split.
|
||||
importances = {}
|
||||
for name in SHIP_MODELS:
|
||||
result = permutation_importance(
|
||||
fitted[name], X_test, y_test, n_repeats=20, random_state=config.RANDOM_STATE, scoring="average_precision"
|
||||
)
|
||||
imp_df = pd.DataFrame(
|
||||
{"feature": X.columns, "importance_mean": result.importances_mean, "importance_std": result.importances_std}
|
||||
).sort_values("importance_mean", ascending=False)
|
||||
imp_df.to_csv(OUT_DIR / f"feature_importance_{name}.csv", index=False)
|
||||
importances[name] = imp_df
|
||||
print(f"\nTop 10 features for {name} (permutation importance, PR-AUC drop):")
|
||||
print(imp_df.head(10).to_string(index=False))
|
||||
return table, importances
|
||||
|
||||
|
||||
def fit_final_bundles(X, y):
|
||||
"""Refit each shipped model on ALL available labeled data (standard practice
|
||||
for a deployed artifact -- validated metrics above already establish that
|
||||
generalization performance holds up on unseen individuals/institutions)."""
|
||||
spw = (y == 0).sum() / (y == 1).sum()
|
||||
candidates = {
|
||||
**models.advanced_models(scale_pos_weight=spw),
|
||||
"stacking_ensemble": models.stacking_model(scale_pos_weight=spw),
|
||||
}
|
||||
numeric_columns = [c for c in config.RQ1_NUMERIC_COLUMNS if c not in UNAVAILABLE_COLUMNS]
|
||||
# Persist the *actual* categories seen at training time for each research-area
|
||||
# column (needed to reindex one-hot columns identically at inference time).
|
||||
raw_df = data.load_rq1_raw()
|
||||
broad_categories = {
|
||||
col: sorted(data._broad_research_area(raw_df[col]).unique().tolist()) for col in RESEARCH_AREA_COLUMNS
|
||||
}
|
||||
|
||||
for name in SHIP_MODELS:
|
||||
model = candidates[name]
|
||||
model.fit(X, y)
|
||||
bundle = {
|
||||
"model": model,
|
||||
"model_name": name,
|
||||
"feature_columns": X.columns.tolist(),
|
||||
"numeric_columns": numeric_columns,
|
||||
"log_columns": [c for c in config.RQ1_LOG_COLUMNS if c not in UNAVAILABLE_COLUMNS],
|
||||
"research_area_columns": RESEARCH_AREA_COLUMNS,
|
||||
"research_area_categories": broad_categories,
|
||||
"label_meaning": {0: "non-founder", 1: "founder"},
|
||||
}
|
||||
out_path = MODELS_DIR / f"{name}.joblib"
|
||||
joblib.dump(bundle, out_path)
|
||||
print(f"Saved {out_path} ({out_path.stat().st_size / 1024:.0f} KB)")
|
||||
|
||||
|
||||
def main():
|
||||
raw_df = data.load_rq1_raw()
|
||||
X, y, _ = build_production_matrix(raw_df)
|
||||
print(f"Production feature matrix: {X.shape[0]} rows x {X.shape[1]} columns\n")
|
||||
|
||||
table, importances = rank_and_validate(X, y)
|
||||
top2 = table.index[:2].tolist()
|
||||
print(f"\nTop-2 by PR-AUC on production feature set: {top2}")
|
||||
|
||||
fit_final_bundles(X, y)
|
||||
|
||||
manifest = {
|
||||
"shipped_models": SHIP_MODELS,
|
||||
"feature_count": X.shape[1],
|
||||
"unavailable_columns_dropped": UNAVAILABLE_COLUMNS,
|
||||
"institution_onehot_dropped": True,
|
||||
}
|
||||
with open(OUT_DIR / "manifest.json", "w") as f:
|
||||
json.dump(manifest, f, indent=2)
|
||||
print("\nDone.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,88 +0,0 @@
|
||||
feature,importance_mean,importance_std
|
||||
publications,0.49372270392208406,0.009435105555281502
|
||||
pub_citation_sum,0.10041155476971034,0.003075116147541558
|
||||
last_patent_year,0.08897556673923894,0.00369039716968687
|
||||
pub_citation_mean,0.05843840173995631,0.0035635258840383387
|
||||
i10-index,0.058276972447521766,0.0028493921400149316
|
||||
g-index,0.03926107174812248,0.002908392365462608
|
||||
activities_total,0.02269603064081724,0.0014262023325240447
|
||||
grants,0.022629143919601975,0.0018617301145260297
|
||||
first_publication_year,0.016383482397344773,0.0014781488366511484
|
||||
last_publication_year,0.01044333199563966,0.0012914478475198282
|
||||
last_grant_year,0.008814204773467744,0.0006485422255609053
|
||||
patents,0.007948968544722036,0.00072369450238458
|
||||
publication_research_area_32,0.004622593405503084,0.0005567329882739705
|
||||
industry_collab_papers,0.004127688678751134,0.0005178389595278936
|
||||
affiliations,0.0038678024032746117,0.0006972880130649415
|
||||
first_patent_year,0.003812250467041056,0.000739110083304315
|
||||
first_grant_year,0.0030673049491659722,0.0005750427084734693
|
||||
h-index,0.0026992385419333962,0.00038040011240434297
|
||||
grant_research_area_32,0.0024383846686938824,0.0006597174523401329
|
||||
grant_research_impact,0.002092380085101797,0.0009209829823855754
|
||||
patent_research_area_46,0.0015450646662926114,0.0003408238801588627
|
||||
publication_research_area_46,0.0011186842180353428,0.0003636648316547925
|
||||
publication_research_area_31,0.0007689503487253891,0.0003229045550739315
|
||||
publication_research_area_35,0.000357006395234688,0.000184261296332344
|
||||
patent_research_area_35,0.0003289822271172027,0.0002457177044892662
|
||||
grant_research_area_46,0.0003235675420170059,0.00012528589983147148
|
||||
patent_research_area_32,0.000284992232621617,9.07382535848989e-05
|
||||
publication_research_area_42,0.00017982554980572885,0.00010724763462688804
|
||||
publication_research_area_51,0.00015147606865889007,0.00017482583322384033
|
||||
publication_research_area_33,0.00014482998247801194,0.00014293663951790765
|
||||
publication_research_area_44,0.0001390054811560959,5.095898280286692e-05
|
||||
grant_research_area_42,0.00010679798913335037,0.00011517614876712806
|
||||
publication_research_area_52,7.58659457399391e-05,8.67872358194002e-05
|
||||
publication_research_area_n.,3.733479496259573e-05,8.266304276802761e-05
|
||||
publication_research_area_47,3.577968510939944e-05,3.644548262290321e-05
|
||||
grant_research_area_33,2.7053741977389746e-05,1.3158619878764252e-05
|
||||
publication_research_area_39,2.6107088659182988e-05,5.314752896673858e-05
|
||||
patent_research_area_40,2.293468269031207e-05,5.522677589407406e-05
|
||||
publication_research_area_30,2.1227363888909333e-05,4.0118754214761545e-05
|
||||
grant_research_area_52,1.86106929250307e-05,4.737938770158699e-05
|
||||
grant_research_area_31,1.7230231395626296e-05,3.303598252316633e-05
|
||||
grant_research_area_36,1.5591805886239208e-05,1.4155029297892755e-05
|
||||
grant_research_area_34,1.5538090563826935e-05,6.936899814614872e-05
|
||||
grant_research_area_51,1.516446191183185e-05,5.6983277869360076e-05
|
||||
publication_research_area_36,1.4576087392986769e-05,2.765828911048998e-05
|
||||
patent_research_area_34,1.2943329198150666e-05,3.9589156048043156e-05
|
||||
publication_research_area_40,1.0268854792233605e-05,0.00010816661742277235
|
||||
patent_research_area_31,7.878647505654702e-06,2.0077897722361337e-05
|
||||
grant_research_area_30,2.291815734967173e-06,4.65029322854696e-06
|
||||
publication_research_area_38,1.9069228478219014e-06,8.771931389052964e-05
|
||||
patent_research_area_41,6.061759097786279e-07,9.166702390722687e-06
|
||||
publication_research_area_43,2.6636266048374323e-08,1.1610479193812715e-07
|
||||
grant_research_area_37,0.0,0.0
|
||||
grant_research_area_49,0.0,0.0
|
||||
grant_research_area_50,0.0,0.0
|
||||
grant_research_area_43,0.0,0.0
|
||||
grant_research_area_44,0.0,0.0
|
||||
patent_research_area_52,0.0,0.0
|
||||
grant_research_area_47,0.0,0.0
|
||||
grant_research_area_48,0.0,0.0
|
||||
grant_research_area_38,0.0,0.0
|
||||
patent_research_area_47,0.0,0.0
|
||||
patent_research_area_39,0.0,0.0
|
||||
patent_research_area_38,0.0,0.0
|
||||
patent_research_area_50,0.0,0.0
|
||||
patent_research_area_49,0.0,0.0
|
||||
patent_research_area_48,0.0,0.0
|
||||
patent_research_area_33,0.0,0.0
|
||||
patent_research_area_44,0.0,0.0
|
||||
patent_research_area_43,0.0,0.0
|
||||
patent_research_area_42,0.0,0.0
|
||||
publication_research_area_50,0.0,0.0
|
||||
patent_research_area_36,0.0,0.0
|
||||
patent_research_area_37,0.0,0.0
|
||||
publication_research_area_48,0.0,0.0
|
||||
grant_research_area_35,-1.417609221954219e-07,6.811830057220157e-06
|
||||
patent_research_area_30,-2.1125354582318678e-07,5.786182703937211e-06
|
||||
publication_research_area_41,-3.4822477430085376e-06,5.216332045233262e-05
|
||||
grant_research_area_40,-3.6317530620000316e-06,1.3350040147139044e-05
|
||||
publication_research_area_34,-3.646016761565951e-06,7.33822378850038e-05
|
||||
grant_research_area_39,-7.1453723731962345e-06,7.890200374144198e-06
|
||||
publication_research_area_49,-1.1344775302907229e-05,8.151635605591815e-06
|
||||
patent_research_area_51,-1.6526341596556638e-05,1.1059230863873912e-05
|
||||
patent_research_area_n.,-2.1720602983060776e-05,7.506139221086442e-05
|
||||
publication_research_area_37,-2.9818072529441686e-05,1.7457265886226128e-05
|
||||
grant_research_area_n.,-4.7040468339543115e-05,0.00011100424284573038
|
||||
grant_research_area_41,-0.0001130957822619516,2.660738658933989e-05
|
||||
|
@@ -1,88 +0,0 @@
|
||||
feature,importance_mean,importance_std
|
||||
publications,0.3230278846487044,0.008800711081034392
|
||||
last_patent_year,0.08101404353937798,0.003480354323912183
|
||||
pub_citation_sum,0.06944573429242025,0.0023742502139718533
|
||||
pub_citation_mean,0.04195885153037786,0.002746357604547681
|
||||
i10-index,0.03509514754261644,0.002072326739488329
|
||||
g-index,0.03475697537302609,0.0027920726906895555
|
||||
activities_total,0.020832913783627394,0.0014390050076316802
|
||||
grants,0.019315451629353792,0.001705491344778238
|
||||
first_publication_year,0.01533644702358411,0.001435861122416683
|
||||
patents,0.008735459919303962,0.0008664045277148187
|
||||
last_grant_year,0.00852538114821349,0.0008305351559872533
|
||||
last_publication_year,0.008331716857098981,0.0011919353376131424
|
||||
first_patent_year,0.004574821675796192,0.0008880825668646626
|
||||
publication_research_area_32,0.004441482221912802,0.0005572418844014392
|
||||
industry_collab_papers,0.003930523472063801,0.0005518946751113055
|
||||
affiliations,0.0030599567623114943,0.0010611086743104593
|
||||
h-index,0.0022261144135681645,0.0005336009903611933
|
||||
first_grant_year,0.001877805851533959,0.0005896264410466552
|
||||
grant_research_impact,0.0016329087316583224,0.0008953253954886791
|
||||
patent_research_area_46,0.0014940981662886431,0.00037841991074793763
|
||||
publication_research_area_46,0.0011952487055542527,0.00034735364248049394
|
||||
grant_research_area_32,0.0010669398974483101,0.0005455308275487198
|
||||
publication_research_area_31,0.0007084035131517119,0.00039455107739638177
|
||||
patent_research_area_32,0.0004949758173996676,0.00013130610768396822
|
||||
publication_research_area_35,0.0003405892771618013,0.00018230752010422918
|
||||
patent_research_area_35,0.00024248321741005552,0.00020196690479766595
|
||||
grant_research_area_46,0.00023508021158918924,9.949654281666699e-05
|
||||
patent_research_area_31,0.00018850830793534779,1.8256292436730253e-05
|
||||
publication_research_area_42,0.0001534410024302102,0.00011124851671888089
|
||||
publication_research_area_51,0.00014695613247396323,0.0001875329044078893
|
||||
publication_research_area_33,0.00013417272910902777,0.00013187331917677777
|
||||
publication_research_area_44,0.00012981751828511912,5.6292634597364995e-05
|
||||
grant_research_area_42,5.536599990074165e-05,9.314538927088949e-05
|
||||
publication_research_area_52,4.569653237913584e-05,7.131642881143011e-05
|
||||
grant_research_area_31,4.1136563865012964e-05,2.3807980697386147e-05
|
||||
patent_research_area_n.,3.185352984812484e-05,0.00011635744728257203
|
||||
publication_research_area_39,2.6622233316087042e-05,5.5811212973079166e-05
|
||||
grant_research_area_51,2.4725683306386914e-05,6.600893864529117e-05
|
||||
publication_research_area_47,2.433370482673447e-05,3.423391460291853e-05
|
||||
patent_research_area_40,1.8682066021558085e-05,8.373831667931168e-05
|
||||
grant_research_area_52,1.736850855706962e-05,4.3586661490832724e-05
|
||||
grant_research_area_33,1.5434425911642348e-05,7.2096436009871756e-06
|
||||
publication_research_area_36,1.4747622070127031e-05,2.0277087228790355e-05
|
||||
grant_research_area_36,1.142451025916702e-05,6.434576027802877e-06
|
||||
patent_research_area_34,8.701666157134858e-06,5.019098976931235e-05
|
||||
grant_research_area_44,4.732059862427862e-06,7.2140691084721474e-06
|
||||
grant_research_area_37,4.64755563436281e-06,5.030937947155093e-07
|
||||
patent_research_area_41,2.4010968401655396e-06,5.567934448611626e-06
|
||||
patent_research_area_30,1.6321848824496498e-06,5.780242227170541e-06
|
||||
publication_research_area_38,9.905339116711431e-07,8.061592993393422e-05
|
||||
grant_research_area_30,9.659275313156358e-07,2.7523076304409766e-06
|
||||
publication_research_area_43,5.303685287838533e-07,1.367136262691942e-07
|
||||
patent_research_area_49,4.579606428523064e-07,0.0
|
||||
patent_research_area_37,3.063681887460756e-07,1.7298092956127215e-06
|
||||
grant_research_area_43,2.3512457243968222e-07,8.230462484551701e-07
|
||||
grant_research_area_38,2.3508913500336347e-07,8.200887763327234e-07
|
||||
grant_research_area_48,5.8234010574809145e-08,9.530097523591368e-07
|
||||
patent_research_area_33,3.072036073303863e-08,2.2691555351810873e-07
|
||||
publication_research_area_48,1.7983012212674508e-08,2.2325824775832636e-07
|
||||
patent_research_area_36,1.7241796396172405e-08,7.515524809601928e-08
|
||||
publication_research_area_50,6.931049512104437e-10,3.8784698331014374e-07
|
||||
grant_research_area_47,0.0,0.0
|
||||
patent_research_area_44,0.0,0.0
|
||||
patent_research_area_52,0.0,0.0
|
||||
patent_research_area_50,0.0,0.0
|
||||
patent_research_area_38,0.0,0.0
|
||||
patent_research_area_39,0.0,0.0
|
||||
patent_research_area_43,0.0,0.0
|
||||
patent_research_area_47,-1.1949865169613717e-08,3.48654680192657e-07
|
||||
grant_research_area_50,-2.1918295900480445e-08,3.3714424966572567e-07
|
||||
grant_research_area_49,-8.055305700249704e-08,1.891835873709255e-07
|
||||
patent_research_area_48,-4.387378193082547e-07,1.0065335879337318e-07
|
||||
grant_research_area_35,-1.4239535029381135e-06,8.577025403596155e-06
|
||||
grant_research_area_40,-2.8211226388352716e-06,5.5951614108796825e-06
|
||||
patent_research_area_42,-3.3309781069246203e-06,1.8056260442298824e-06
|
||||
patent_research_area_51,-6.034520616637895e-06,9.657390477461269e-06
|
||||
grant_research_area_34,-6.555808500358085e-06,5.834666117024457e-05
|
||||
publication_research_area_30,-6.9231426525317994e-06,2.3604223992407287e-05
|
||||
grant_research_area_39,-7.033697191549671e-06,4.692880133162641e-06
|
||||
publication_research_area_41,-1.6315314521198056e-05,3.6394138064735864e-05
|
||||
publication_research_area_49,-2.0970323580088435e-05,1.491599600665608e-05
|
||||
publication_research_area_37,-2.4155344697468494e-05,1.268437871622249e-05
|
||||
publication_research_area_40,-2.4661278046128608e-05,9.362093188879351e-05
|
||||
publication_research_area_34,-4.671501475140283e-05,6.79190773369875e-05
|
||||
grant_research_area_n.,-6.528496794626637e-05,0.00033896991853285866
|
||||
grant_research_area_41,-8.826418872341368e-05,2.1901303480798616e-05
|
||||
publication_research_area_n.,-8.850450506823205e-05,0.00012674501058303883
|
||||
|
@@ -1,109 +0,0 @@
|
||||
"""Self-contained inference wrapper for the founder-potential classifier.
|
||||
|
||||
Depends only on pandas, numpy and joblib -- no dependency on the `experiments/src`
|
||||
research package, so this file + a `models/*.joblib` bundle can be copied into any
|
||||
other codebase.
|
||||
|
||||
Usage:
|
||||
from founder_classifier import FounderClassifier
|
||||
|
||||
clf = FounderClassifier.load("models/lightgbm.joblib")
|
||||
result = clf.predict_one({
|
||||
"h-index": 12, "i10-index": 15, "publications": 40,
|
||||
"pub_citation_mean": 22.5, "pub_citation_sum": 900,
|
||||
"first_publication_year": 2005, "last_publication_year": 2021,
|
||||
"patents": 2, "first_patent_year": 2015, "last_patent_year": 2018,
|
||||
"grants": 3, "first_grant_year": 2010, "last_grant_year": 2019,
|
||||
"affiliations": 2, "activities_total": 45, "g-index": 10,
|
||||
"industry_collab_papers": 4, "grant_research_impact": 5,
|
||||
"publication_research_area": "32", "patent_research_area": "32",
|
||||
"grant_research_area": "32",
|
||||
})
|
||||
print(result) # {'prediction': 1, 'probability_founder': 0.87, ...}
|
||||
|
||||
See README.md in this directory for the full input schema and output format.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import joblib
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class FounderClassifier:
|
||||
"""Wraps a fitted sklearn/LightGBM classifier bundle produced by
|
||||
`export_classifier.py`, handling feature preprocessing (log1p transforms +
|
||||
research-area one-hot encoding) so callers can pass plain feature dicts."""
|
||||
|
||||
def __init__(self, bundle: dict[str, Any]):
|
||||
self._model = bundle["model"]
|
||||
self.model_name: str = bundle["model_name"]
|
||||
self.feature_columns: list[str] = bundle["feature_columns"]
|
||||
self.numeric_columns: list[str] = bundle["numeric_columns"]
|
||||
self.log_columns: list[str] = bundle["log_columns"]
|
||||
self.research_area_columns: list[str] = bundle["research_area_columns"]
|
||||
self.research_area_categories: dict[str, list[str]] = bundle["research_area_categories"]
|
||||
|
||||
@classmethod
|
||||
def load(cls, path: str | Path) -> "FounderClassifier":
|
||||
return cls(joblib.load(path))
|
||||
|
||||
# -- preprocessing -----------------------------------------------------
|
||||
@staticmethod
|
||||
def _broad_research_area(value: Any) -> str:
|
||||
"""Collapse a research-area code to its 2-character broad category,
|
||||
matching the training-time `data._broad_research_area` transform."""
|
||||
if value is None or (isinstance(value, float) and np.isnan(value)):
|
||||
return "n."
|
||||
return str(value).strip()[:2]
|
||||
|
||||
def _to_frame(self, records: list[dict[str, Any]]) -> pd.DataFrame:
|
||||
df = pd.DataFrame.from_records(records, index=range(len(records)))
|
||||
|
||||
# Missing numeric/categorical columns default to 0 / "n." (matches
|
||||
# training-time fillna(0) for any column that couldn't be parsed as
|
||||
# numeric, and the "n.a." fallback in data._broad_research_area).
|
||||
for col in self.numeric_columns:
|
||||
if col not in df.columns:
|
||||
df[col] = 0
|
||||
numeric = df[self.numeric_columns].apply(pd.to_numeric, errors="coerce").fillna(0)
|
||||
for col in self.log_columns:
|
||||
numeric[col] = np.log1p(numeric[col].clip(lower=0))
|
||||
|
||||
for col in self.research_area_columns:
|
||||
if col not in df.columns:
|
||||
df[col] = None
|
||||
cat_df = pd.DataFrame(
|
||||
{col: df[col].apply(self._broad_research_area) for col in self.research_area_columns}
|
||||
)
|
||||
categorical = pd.get_dummies(cat_df, prefix=cat_df.columns.tolist())
|
||||
|
||||
X = pd.concat([numeric, categorical], axis=1)
|
||||
# Reindex to the exact training-time column order; any research-area
|
||||
# category not seen during training (or missing here) becomes all-zero
|
||||
# for that one-hot block, which tree models handle gracefully.
|
||||
X = X.reindex(columns=self.feature_columns, fill_value=0)
|
||||
return X
|
||||
|
||||
# -- public API ----------------------------------------------------------
|
||||
def predict(self, records: list[dict[str, Any]]) -> pd.DataFrame:
|
||||
"""Batch prediction. `records` is a list of raw feature dicts (see
|
||||
README for the input schema). Returns a DataFrame with one row per
|
||||
input record: `prediction` (0/1) and `probability_founder` (0-1)."""
|
||||
X = self._to_frame(records)
|
||||
proba = self._model.predict_proba(X)[:, 1]
|
||||
pred = (proba >= 0.5).astype(int)
|
||||
return pd.DataFrame({"prediction": pred, "probability_founder": proba})
|
||||
|
||||
def predict_one(self, record: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Single-record convenience wrapper around `predict`."""
|
||||
row = self.predict([record]).iloc[0]
|
||||
return {
|
||||
"prediction": int(row["prediction"]),
|
||||
"probability_founder": float(row["probability_founder"]),
|
||||
"label": "founder" if row["prediction"] == 1 else "non-founder",
|
||||
"model": self.model_name,
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"shipped_models": [
|
||||
"lightgbm",
|
||||
"stacking_ensemble"
|
||||
],
|
||||
"feature_count": 87,
|
||||
"unavailable_columns_dropped": [
|
||||
"pat_citation_mean",
|
||||
"pat_citation_sum",
|
||||
"linked_patents_to_publications",
|
||||
"grant_innovation_impact"
|
||||
],
|
||||
"institution_onehot_dropped": true
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
model,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
lightgbm,0.9293725371324644,0.9161016949152543,0.8897119341563786,0.902713987473904,0.9763933319115661,0.9680867355662728,0.8475189762274824,0.05343925129722402
|
||||
stacking_ensemble,0.9284631706577751,0.9009009009009009,0.9053497942386831,0.90311986863711,0.9748029272608074,0.9657412183896399,0.8464233584967953,0.05796028500367217
|
||||
xgboost,0.927250682024856,0.9079497907949791,0.8930041152263375,0.9004149377593361,0.9728476023474957,0.9640546196916957,0.8431866284933476,0.05821008235216141
|
||||
catboost,0.9227038496514095,0.8993344425956739,0.8897119341563786,0.8944973107157633,0.9709767935988879,0.9616152397971783,0.833539926599779,0.061886894004821225
|
||||
random_forest,0.8911791451955138,0.8639455782312925,0.8362139917695474,0.849853617733166,0.9489078062921099,0.9295025250699936,0.764805465144283,0.09198073526810191
|
||||
svm_rbf,0.8742043043346469,0.8424657534246576,0.8098765432098766,0.8258497691984893,0.9312032495280522,0.8989506133295394,0.7277986141772655,0.09551038087976692
|
||||
|
@@ -1,97 +0,0 @@
|
||||
# Founder classifier v2 (symmetric landmark design)
|
||||
|
||||
Replaces `../classifier` (v1). **v1 must not be used for ranking or coaching:**
|
||||
it was trained with asymmetric observation windows (founders truncated at
|
||||
founding, non-founders full-career) and behaves as an inverse-productivity
|
||||
score in production — 1 publication → P(founder)=0.996, 800 → 0.0002. Its
|
||||
0.976 ROC-AUC was inflated by window-length leakage, and the companion
|
||||
`p_within_3y`/`p_within_5y` outputs were degenerate (exactly 1.0 for every
|
||||
author).
|
||||
|
||||
## What changed
|
||||
|
||||
| | v1 (asymmetric) | v2 (symmetric) |
|
||||
|---|---|---|
|
||||
| Observation window | founders truncated at founding; non-founders full career | every person truncated at an index year (real founding / cohort-matched pseudo-founding), identical construction for both classes |
|
||||
| Citation features (h-index, i10, g-index, citation sums) | included, window-contaminated | excluded — not historicizable to an index date |
|
||||
| `grants` | raw (consortium lists inflate ~100×, up to 409 grants/paper) | de-inflated via per-paper cap mapping (cap 10), applied inside the wrapper |
|
||||
| Institution one-hots | included | excluded — production scores people from arbitrary institutions |
|
||||
| Population | anyone matched | academics only: ≥4 publications at index (both classes), plausibility-filtered (see below) |
|
||||
| Headline holdout | ROC-AUC 0.976 / PR-AUC 0.969 (artifact) | ROC-AUC 0.874 / PR-AUC 0.726 (honest); temporal-split PR-AUC ≈0.73; 5-fold OOF 0.866/0.726 |
|
||||
| P(founder) vs output | strictly decreasing, incl. absurd tail (1 pub → 0.996) | plateau ~0.39–0.42 for 5–17 pubs at index, ~0.10–0.18 for 100+ (matches empirical label rates) |
|
||||
| p_within_{1,3,5}y | 3y/5y ≡ 1.0 for everyone | all horizons discriminate (ROC-AUC 0.86–0.89; ≤0.1% of scores above 0.99) |
|
||||
| Coach-facing number | raw probability | **percentile** vs the ~9k-academic reference cohort, with an out-of-population guard |
|
||||
|
||||
Two dataset artifacts beyond the window asymmetry were found and filtered
|
||||
during the rebuild, both class-asymmetric (rules applied to BOTH classes):
|
||||
|
||||
- **Sampling-frame clash on thin profiles.** Founders come from company
|
||||
databases (people with 1–3 lifetime papers included); non-founders from
|
||||
institutional researcher lists (thin profiles underrepresented). Left in,
|
||||
"long career + tiny record" reads as 65–72% founder. Hence the ≥4
|
||||
publications population rule, enforced at inference by `in_population`.
|
||||
- **Name-collision aggregates.** Non-founders matched by name alone merge
|
||||
multiple researchers (e.g. an "M Nakamura" spanning 1919–2023 with 28,050
|
||||
papers); 4.2% of non-founders vs 2.2% of founders had physically impossible
|
||||
profiles (>60-year span or >25 papers/year sustained). These rows are
|
||||
dropped.
|
||||
|
||||
Training details: `experiments/docs/DESIGN_NOTES.md` (design rationale), `experiments/src/symmetric.py`,
|
||||
`experiments/run_rq1_symmetric.py`, `experiments/run_rq2_symmetric.py`;
|
||||
results in `experiments/results/rq1_symmetric` and `rq2_symmetric`.
|
||||
|
||||
## Interpreting the outputs
|
||||
|
||||
- `percentile` (0–100): rank of the person's score against out-of-fold scores
|
||||
of the reference cohort (founders + non-founders from the 8 training
|
||||
institutions). This is the number to surface to coaches ("higher founding
|
||||
propensity than X% of comparable academics").
|
||||
- `probability_founder` (0–1): raw case-control model output. The training
|
||||
cohort is ~26% founders — far above any real-world base rate — so this is
|
||||
NOT a population founding probability. Do not display it as one.
|
||||
- `p_within_{k}y` bundles: same construction at index−k; conditional-timing
|
||||
evidence, same percentile caveat.
|
||||
|
||||
## Input contract (per record)
|
||||
|
||||
Lifetime totals **as of `scoring_year`** (for live profiles: the current year):
|
||||
`publications`, `patents`, `grants` (raw — the wrapper de-inflates),
|
||||
`first_publication_year`, `first_patent_year`, `first_grant_year`,
|
||||
`industry_collab_papers`, `linked_patents_to_publications`,
|
||||
`publication_research_area`, `patent_research_area`, `grant_research_area`.
|
||||
Missing fields default to 0 / "n.a.". Citation fields are accepted but ignored.
|
||||
|
||||
```python
|
||||
from founder_classifier_v2 import FounderClassifierV2
|
||||
clf = FounderClassifierV2.load("models/founder_classifier_v2.joblib")
|
||||
clf.predict_one({...}, scoring_year=2026)
|
||||
```
|
||||
|
||||
## Migrating smart-guide `profiling/multipliers/founding.py`
|
||||
|
||||
1. Copy this directory (wrapper + `models/*.joblib`) next to the v1 classifier.
|
||||
2. Point the classifier loader at `founder_classifier_v2.joblib` and pass
|
||||
`scoring_year` (extraction snapshot year).
|
||||
3. Surface `percentile` as `founding.percentile`; keep `probability_founder`
|
||||
internal. Replace the degenerate `p_within_3y/5y` fields with the v2
|
||||
bundles' outputs.
|
||||
4. Remove the README stop-block once v1 is no longer referenced.
|
||||
|
||||
## Known limitations (documented, not hidden)
|
||||
|
||||
- Non-founder historical snapshots are curve-estimates (empirical career
|
||||
curves fitted on founders' raw per-year records; log-space R² 0.89–0.94 vs
|
||||
ground truth), because non-founders' per-record data was never saved and the
|
||||
Dimensions API key is dead. Founders' snapshots use the same construction so
|
||||
fidelity is class-symmetric.
|
||||
- Pseudo-founding years for non-founders are sampled (seeded) from the
|
||||
founders' career-age-at-founding distribution, cohort-matched by decade of
|
||||
first publication.
|
||||
- Reference cohort is 8 research universities, index years ≈1950–2023; scoring
|
||||
profiles far outside that population extrapolates.
|
||||
- Conditional on career age, the score declines with publication volume beyond
|
||||
~20–40 papers at index (hyper-prolific researchers found less in this
|
||||
cohort). The empirical label rates support it after cleaning, but residual
|
||||
moderate name-collisions in the non-founder class could still contribute.
|
||||
Communicate to coaches as "the model favours focused mid-volume researchers",
|
||||
and treat very-high-output percentiles as conservative.
|
||||
@@ -1,99 +0,0 @@
|
||||
"""Export the symmetric founder classifier as a self-contained v2 bundle.
|
||||
|
||||
Produces models/founder_classifier_v2.joblib (and p_within_{k}y bundles) with:
|
||||
- the final model refit on the full symmetric dataset;
|
||||
- preprocessing metadata (feature order, log columns, research-area columns);
|
||||
- the grants de-inflation mapping fitted on raw founder records;
|
||||
- reference score quantiles for percentile ranking, computed from 5-fold
|
||||
OUT-OF-FOLD predictions (in-sample scores would shift live percentiles).
|
||||
|
||||
Run with: conda run -n potential python experiments/production/classifier_symmetric/export_classifier_v2.py
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import joblib
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from sklearn.model_selection import StratifiedKFold, cross_val_predict
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
sys.path.insert(0, str(HERE.parents[1]))
|
||||
|
||||
from src import career_curves as cc
|
||||
from src import config, models, symmetric
|
||||
|
||||
MODELS_DIR = HERE / "models"
|
||||
PRIMARY = "lightgbm"
|
||||
|
||||
|
||||
def _grants_cap_table():
|
||||
"""The binned r -> capped_share mapping as plain arrays for the bundle."""
|
||||
yearly = cc.load_yearly()
|
||||
per_person = yearly.groupby("author_people").agg(
|
||||
pubs=("pubs", "sum"), grants=("grants", "sum"), capped=("grants_capped", "sum")
|
||||
)
|
||||
per_person = per_person[per_person["grants"] > 0]
|
||||
r = per_person["grants"] / per_person["pubs"].clip(lower=1)
|
||||
share = per_person["capped"] / per_person["grants"]
|
||||
bins = np.unique(np.quantile(r, np.linspace(0, 1, 21)))
|
||||
idx = np.clip(np.digitize(r, bins) - 1, 0, len(bins) - 2)
|
||||
binned = pd.DataFrame({"bin": idx, "share": share}).groupby("bin")["share"].median()
|
||||
centers = (bins[:-1] + bins[1:]) / 2
|
||||
return centers[binned.index.to_numpy()], binned.to_numpy()
|
||||
|
||||
|
||||
def _export(feats, X, y, label, model_name):
|
||||
spw = (y == 0).sum() / (y == 1).sum()
|
||||
model = models.advanced_models(scale_pos_weight=spw)[model_name]
|
||||
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=config.RANDOM_STATE)
|
||||
oof = cross_val_predict(model, X, y, cv=cv, method="predict_proba", n_jobs=-1)[:, 1]
|
||||
model.fit(X, y)
|
||||
|
||||
cap_r, cap_share = _grants_cap_table()
|
||||
bundle = {
|
||||
"model": model,
|
||||
"model_name": f"{model_name}_symmetric_{label}",
|
||||
"feature_columns": X.columns.tolist(),
|
||||
"numeric_columns": symmetric.SYMMETRIC_NUMERIC_COLUMNS,
|
||||
"log_columns": symmetric.SYMMETRIC_LOG_COLUMNS,
|
||||
"research_area_columns": [
|
||||
"publication_research_area", "patent_research_area", "grant_research_area"],
|
||||
"grants_cap_r": cap_r,
|
||||
"grants_cap_share": cap_share,
|
||||
"reference_score_quantiles": np.quantile(oof, np.linspace(0, 1, 1001)),
|
||||
}
|
||||
out = MODELS_DIR / f"{label}.joblib"
|
||||
joblib.dump(bundle, out)
|
||||
from sklearn.metrics import average_precision_score, roc_auc_score
|
||||
stats = {
|
||||
"rows": int(len(X)), "founders": int(y.sum()),
|
||||
"oof_roc_auc": round(float(roc_auc_score(y, oof)), 4),
|
||||
"oof_pr_auc": round(float(average_precision_score(y, oof)), 4),
|
||||
}
|
||||
print(f"{label}: {stats}")
|
||||
return {"file": out.name, "model": bundle["model_name"], **stats}
|
||||
|
||||
|
||||
def main():
|
||||
MODELS_DIR.mkdir(exist_ok=True)
|
||||
manifest = {"design": "symmetric landmark (see experiments/src/symmetric.py)", "bundles": []}
|
||||
|
||||
feats, attrition = symmetric.build_symmetric_dataset()
|
||||
X, y, _ = symmetric.build_matrix(feats, include_institution=False)
|
||||
manifest["attrition"] = {k: int(v) for k, v in attrition.items()}
|
||||
manifest["bundles"].append(_export(feats, X, y, "founder_classifier_v2", PRIMARY))
|
||||
|
||||
for k in [1, 3, 5]:
|
||||
feats_k, _ = symmetric.build_symmetric_dataset(offset=k)
|
||||
feats_k = feats_k[feats_k["pubs_at_index"] > 0].reset_index(drop=True)
|
||||
Xk, yk, _ = symmetric.build_matrix(feats_k, include_institution=False)
|
||||
manifest["bundles"].append(_export(feats_k, Xk, yk, f"p_within_{k}y_v2", PRIMARY))
|
||||
|
||||
(HERE / "manifest.json").write_text(json.dumps(manifest, indent=2))
|
||||
print(f"Manifest written to {HERE / 'manifest.json'}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,150 +0,0 @@
|
||||
"""Self-contained inference wrapper for the SYMMETRIC founder-potential classifier.
|
||||
|
||||
Depends only on pandas, numpy and joblib. Replaces v1 (../classifier), which
|
||||
must not be used for ranking — see README.md in this directory for what changed,
|
||||
the input contract and how to read the outputs.
|
||||
|
||||
Three contract points the caller must get right:
|
||||
- `predict` requires `scoring_year`, the year the profile snapshot was taken.
|
||||
- `percentile` is the coach-facing output; `probability_founder` is a raw
|
||||
case-control score (~26% training base rate) and is NOT a population
|
||||
founding probability.
|
||||
- Pass `grants` RAW — the wrapper applies the training per-paper cap itself.
|
||||
|
||||
Usage:
|
||||
from founder_classifier_v2 import FounderClassifierV2
|
||||
|
||||
clf = FounderClassifierV2.load("models/founder_classifier_v2.joblib")
|
||||
result = clf.predict_one({
|
||||
"publications": 40, "patents": 2, "grants": 3,
|
||||
"first_publication_year": 2005,
|
||||
"first_patent_year": 2015, "first_grant_year": 2010,
|
||||
"industry_collab_papers": 4, "linked_patents_to_publications": 1,
|
||||
"publication_research_area": "32 Biomedical and Clinical Sciences",
|
||||
"patent_research_area": "32", "grant_research_area": "32",
|
||||
}, scoring_year=2026)
|
||||
# {'percentile': 71.4, 'probability_founder': 0.38, ...}
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import joblib
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class FounderClassifierV2:
|
||||
def __init__(self, bundle: dict[str, Any]):
|
||||
self._model = bundle["model"]
|
||||
self.model_name: str = bundle["model_name"]
|
||||
self.feature_columns: list[str] = bundle["feature_columns"]
|
||||
self.numeric_columns: list[str] = bundle["numeric_columns"]
|
||||
self.log_columns: list[str] = bundle["log_columns"]
|
||||
self.research_area_columns: list[str] = bundle["research_area_columns"]
|
||||
# Grants de-inflation: interpolation table r -> capped_share, r = grants/pubs.
|
||||
self.grants_cap_r: np.ndarray = np.asarray(bundle["grants_cap_r"])
|
||||
self.grants_cap_share: np.ndarray = np.asarray(bundle["grants_cap_share"])
|
||||
# Reference score quantiles for percentile ranking (1001 points on [0,1]).
|
||||
self.reference_scores: np.ndarray = np.asarray(bundle["reference_score_quantiles"])
|
||||
|
||||
@classmethod
|
||||
def load(cls, path: str | Path) -> "FounderClassifierV2":
|
||||
return cls(joblib.load(path))
|
||||
|
||||
# -- preprocessing -------------------------------------------------------
|
||||
@staticmethod
|
||||
def _broad_research_area(value: Any) -> str:
|
||||
if value is None or (isinstance(value, float) and np.isnan(value)):
|
||||
return "n."
|
||||
return str(value).strip()[:2]
|
||||
|
||||
def _capped_grants(self, grants: np.ndarray, pubs: np.ndarray) -> np.ndarray:
|
||||
r = grants / np.clip(pubs, 1, None)
|
||||
share = np.interp(r, self.grants_cap_r, self.grants_cap_share)
|
||||
return grants * np.clip(share, 0.0, 1.0)
|
||||
|
||||
def _to_frame(self, records: list[dict[str, Any]], scoring_year: int) -> pd.DataFrame:
|
||||
df = pd.DataFrame.from_records(records, index=range(len(records)))
|
||||
for col in ["publications", "patents", "grants", "first_publication_year",
|
||||
"first_patent_year", "first_grant_year",
|
||||
"industry_collab_papers", "linked_patents_to_publications"]:
|
||||
if col not in df.columns:
|
||||
df[col] = np.nan
|
||||
df[col] = pd.to_numeric(df[col], errors="coerce")
|
||||
|
||||
pubs = df["publications"].fillna(0).to_numpy(dtype=float)
|
||||
pats = df["patents"].fillna(0).to_numpy(dtype=float)
|
||||
grants = self._capped_grants(df["grants"].fillna(0).to_numpy(dtype=float), pubs)
|
||||
first_pub = df["first_publication_year"].to_numpy(dtype=float)
|
||||
career_age = np.clip(scoring_year - first_pub, 1, None)
|
||||
has_pat = (df["first_patent_year"].notna() & (df["first_patent_year"] <= scoring_year)
|
||||
& (pats > 0)).to_numpy()
|
||||
has_grant = (df["first_grant_year"].notna() & (df["first_grant_year"] <= scoring_year)
|
||||
& (grants > 0)).to_numpy()
|
||||
|
||||
numeric = pd.DataFrame({
|
||||
"pubs_at_index": pubs,
|
||||
"patents_at_index": pats,
|
||||
"grants_at_index": grants,
|
||||
"activities_at_index": pubs + pats + grants,
|
||||
"industry_collab_at_index": df["industry_collab_papers"].fillna(0),
|
||||
"linked_pat_pub_at_index": df["linked_patents_to_publications"].fillna(0),
|
||||
"career_age_at_index": career_age,
|
||||
"first_publication_year": first_pub,
|
||||
"pub_rate": pubs / career_age,
|
||||
"patent_rate": pats / career_age,
|
||||
"grant_rate": grants / career_age,
|
||||
"has_patents_at_index": has_pat.astype(int),
|
||||
"has_grants_at_index": has_grant.astype(int),
|
||||
"years_since_first_patent": np.where(
|
||||
has_pat, np.clip(scoring_year - df["first_patent_year"].fillna(scoring_year), 0, None), 0),
|
||||
"years_since_first_grant": np.where(
|
||||
has_grant, np.clip(scoring_year - df["first_grant_year"].fillna(scoring_year), 0, None), 0),
|
||||
})
|
||||
numeric = numeric[self.numeric_columns].fillna(0)
|
||||
for col in self.log_columns:
|
||||
numeric[col] = np.log1p(numeric[col].clip(lower=0))
|
||||
|
||||
cat_df = pd.DataFrame({
|
||||
col: df.get(col, pd.Series([None] * len(df))).apply(self._broad_research_area)
|
||||
for col in self.research_area_columns
|
||||
})
|
||||
categorical = pd.get_dummies(cat_df, prefix=cat_df.columns.tolist())
|
||||
X = pd.concat([numeric, categorical], axis=1)
|
||||
return X.reindex(columns=self.feature_columns, fill_value=0)
|
||||
|
||||
# -- public API ----------------------------------------------------------
|
||||
# The model's population is academics with a minimal record (see
|
||||
# experiments/src/symmetric.py::MIN_PUBS_AT_INDEX): below this, the training
|
||||
# classes come from clashing sampling frames (company databases vs
|
||||
# institutional researcher lists) and scores are not evidence.
|
||||
MIN_PUBLICATIONS = 4
|
||||
|
||||
def predict(self, records: list[dict[str, Any]], scoring_year: int) -> pd.DataFrame:
|
||||
"""`records`: raw profile dicts (lifetime totals as of `scoring_year`).
|
||||
Returns probability_founder (raw case-control score), percentile (rank
|
||||
vs the reference cohort, 0-100; the coach-facing number), and
|
||||
in_population. When in_population is False (fewer than
|
||||
MIN_PUBLICATIONS publications) percentile is NaN: the person is outside
|
||||
the modelled population and must not be ranked."""
|
||||
X = self._to_frame(records, scoring_year)
|
||||
proba = self._model.predict_proba(X)[:, 1]
|
||||
pct = np.interp(proba, self.reference_scores, np.linspace(0, 100, len(self.reference_scores)))
|
||||
pubs = pd.DataFrame.from_records(records).get("publications", pd.Series([0] * len(records)))
|
||||
in_pop = pd.to_numeric(pubs, errors="coerce").fillna(0).to_numpy() >= self.MIN_PUBLICATIONS
|
||||
return pd.DataFrame({
|
||||
"probability_founder": proba,
|
||||
"percentile": np.where(in_pop, np.round(pct, 1), np.nan),
|
||||
"in_population": in_pop,
|
||||
})
|
||||
|
||||
def predict_one(self, record: dict[str, Any], scoring_year: int) -> dict[str, Any]:
|
||||
row = self.predict([record], scoring_year).iloc[0]
|
||||
return {
|
||||
"percentile": None if not row["in_population"] else float(row["percentile"]),
|
||||
"probability_founder": float(row["probability_founder"]),
|
||||
"in_population": bool(row["in_population"]),
|
||||
"model": self.model_name,
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"design": "symmetric landmark (see experiments/src/symmetric.py)",
|
||||
"bundles": [
|
||||
{
|
||||
"file": "founder_classifier_v2.joblib",
|
||||
"model": "lightgbm_symmetric_founder_classifier_v2",
|
||||
"rows": 9017,
|
||||
"founders": 2349,
|
||||
"oof_roc_auc": 0.8659,
|
||||
"oof_pr_auc": 0.7257
|
||||
},
|
||||
{
|
||||
"file": "p_within_1y_v2.joblib",
|
||||
"model": "lightgbm_symmetric_p_within_1y_v2",
|
||||
"rows": 8515,
|
||||
"founders": 2238,
|
||||
"oof_roc_auc": 0.8614,
|
||||
"oof_pr_auc": 0.7154
|
||||
},
|
||||
{
|
||||
"file": "p_within_3y_v2.joblib",
|
||||
"model": "lightgbm_symmetric_p_within_3y_v2",
|
||||
"rows": 7706,
|
||||
"founders": 2010,
|
||||
"oof_roc_auc": 0.861,
|
||||
"oof_pr_auc": 0.7176
|
||||
},
|
||||
{
|
||||
"file": "p_within_5y_v2.joblib",
|
||||
"model": "lightgbm_symmetric_p_within_5y_v2",
|
||||
"rows": 6995,
|
||||
"founders": 1833,
|
||||
"oof_roc_auc": 0.8535,
|
||||
"oof_pr_auc": 0.7038
|
||||
}
|
||||
],
|
||||
"attrition": {
|
||||
"initial": 16822,
|
||||
"no_publication_anchor": 1430,
|
||||
"implausible_profile_founders": 425,
|
||||
"implausible_profile_nonfounders": 770,
|
||||
"founder_bad_founding_year": 340,
|
||||
"founder_bad_career_age": 723,
|
||||
"duplicates": 0,
|
||||
"below_min_pubs_at_index_founders": 1112,
|
||||
"below_min_pubs_at_index_nonfounders": 3005
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
# Founder-Timing Sequence Model — Production Guide
|
||||
|
||||
Given a researcher's **year-by-year publication/patent/grant activity**,
|
||||
predicts how many years into their career a "founding-like" moment falls, and
|
||||
derives a probability of founding within the next 1/2/3/5 years. This is the
|
||||
RQ-sequence model from the research pipeline (LSTM + Transformer), re-packaged
|
||||
for a production app.
|
||||
|
||||
## 1. Which two models, and why
|
||||
|
||||
The two model architectures evaluated (`experiments/results/sequence_founders/sequence_founders_comparison.csv`),
|
||||
ranked by held-out MAE, both far ahead of the naive heuristic (MAE=0.554) and
|
||||
an aggregate-feature Random Forest (MAE=2.571) baseline:
|
||||
|
||||
| rank | model | MAE | RMSE | R2 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | **transformer** | 0.180 | 0.269 | 0.998 |
|
||||
| 2 | **lstm** | 0.208 | 0.258 | 0.998 |
|
||||
|
||||
Both are shipped (`models/transformer.pt`, `models/lstm.pt`) — they are close
|
||||
enough (Δmae=0.028 years, i.e. ~10 days) that using both as a cross-check is
|
||||
worthwhile. `transformer` is marginally better on MAE, `lstm` marginally better
|
||||
on RMSE (fewer large errors); either is a reasonable default.
|
||||
|
||||
**Important scope note:** these predict `founding_age` only for the regime the
|
||||
models were trained and validated on: founders whose company started **within
|
||||
20 years of their first publication**. Founders/candidates outside that range
|
||||
were excluded from training (see `experiments/README.md` "Sequence modeling"
|
||||
section) — treat predictions for very long, established careers (> 20 years
|
||||
of activity with no founding yet) with more caution; the model has not seen
|
||||
that regime.
|
||||
|
||||
## 2. Files
|
||||
|
||||
```
|
||||
production/sequence/
|
||||
founder_timing_model.py <- self-contained wrapper (torch/numpy only)
|
||||
models/
|
||||
transformer.pt <- recommended default
|
||||
lstm.pt <- alternative / second opinion
|
||||
export_sequence_models.py <- reproducible export/training script
|
||||
```
|
||||
|
||||
Each `.pt` is a single bundle: `{model_key, net_kwargs, state_dict, scaler_mean,
|
||||
scaler_std, window, channels, held_out_metrics, held_out_residuals,
|
||||
channel_ablation_mae_delta}`. You only need `founder_timing_model.py` + one
|
||||
`.pt` file to run predictions.
|
||||
|
||||
## 3. Input schema
|
||||
|
||||
The model consumes a **20-year rolling window** (`WINDOW = 20`) of yearly
|
||||
activity counts, ending at a reference year of your choice (typically "now").
|
||||
You provide plain `{year: count}` dictionaries — the wrapper handles
|
||||
alignment, left-zero-padding (for researchers with < 20 years of history) and
|
||||
the log1p transform used at training time:
|
||||
|
||||
```python
|
||||
model.build_sequence(
|
||||
pub_counts_by_year={2015: 2, 2016: 3, 2018: 1, 2020: 4, 2022: 2},
|
||||
pat_counts_by_year={2021: 1},
|
||||
grant_counts_by_year={2019: 1},
|
||||
as_of_year=2023,
|
||||
)
|
||||
```
|
||||
|
||||
| argument | type | description | source |
|
||||
|---|---|---|---|
|
||||
| `pub_counts_by_year` | dict[int, int] | publications per calendar year | OpenAlex works' `publication_year`, grouped/counted per author |
|
||||
| `pat_counts_by_year` | dict[int, int] | patents per calendar year | your patent-matching pipeline |
|
||||
| `grant_counts_by_year` | dict[int, int] | grants/awards per calendar year | your grant-matching pipeline |
|
||||
| `as_of_year` | int | the "reference now" the 20-year window ends at (defaults to the latest year with any activity) | e.g. current year |
|
||||
| `first_publication_year` | int | year of the researcher's first publication (needed only for `years_to_founding` / probability output, not for the raw point estimate) | OpenAlex, min `publication_year` |
|
||||
|
||||
Years outside `[as_of_year - 19, as_of_year]` are ignored; years inside that
|
||||
range with no entry default to a count of 0.
|
||||
|
||||
## 4. Output format
|
||||
|
||||
```python
|
||||
model.predict(
|
||||
pub_counts_by_year=..., pat_counts_by_year=..., grant_counts_by_year=...,
|
||||
first_publication_year=2015, as_of_year=2023,
|
||||
)
|
||||
# {
|
||||
# 'model': 'transformer',
|
||||
# 'predicted_founding_age': 8.4,
|
||||
# 'current_career_age': 8,
|
||||
# 'years_to_founding': 0.4,
|
||||
# 'probability_founds_within': {1: 0.62, 2: 0.87, 3: 0.95, 5: 0.99}
|
||||
# }
|
||||
```
|
||||
|
||||
- `predicted_founding_age`: point estimate — "how many years into a career
|
||||
does this activity pattern, taken as of `as_of_year`, look like a founding
|
||||
moment."
|
||||
- `current_career_age` = `as_of_year - first_publication_year` (only returned
|
||||
if `first_publication_year` is given).
|
||||
- `years_to_founding` = `predicted_founding_age - current_career_age`. Positive
|
||||
means the model expects founding is still that many years away (given the
|
||||
current trajectory); **zero or negative means the current profile already
|
||||
looks like a typical founding-moment profile** — founding could plausibly
|
||||
happen any time now (the model can't distinguish "already overdue" from
|
||||
"right now" — see §6 caveats).
|
||||
- `probability_founds_within`: `{k: P(founds within k years)}` for k in
|
||||
(1, 2, 3, 5) by default (pass `horizons=(...)` to customize) — see §5.
|
||||
|
||||
If you omit `first_publication_year`, you get only `predicted_founding_age`
|
||||
(no probability/timing-to-now fields, since those require knowing the current
|
||||
career age).
|
||||
|
||||
## 5. Probability design (why a residual-based approach, not a retrained model)
|
||||
|
||||
The underlying LSTM/Transformer are **point-estimate regressors** (trained
|
||||
with MSE loss) — they were not retrained with a probabilistic loss for this
|
||||
deliverable, since the existing point predictions are already extremely
|
||||
accurate (R²=0.998, MAE ≈ 2-2.5 months) and retraining risks losing that
|
||||
accuracy for a marginal gain in "native" probability calibration.
|
||||
|
||||
Instead, probability is derived **post-hoc** from the held-out test set's
|
||||
residual distribution (`held_out_residuals` in the bundle, ~460 examples per
|
||||
model): `P(founds within k years) = P(residual <= k - years_to_founding)`,
|
||||
i.e. the empirical fraction of held-out errors small enough that the true
|
||||
founding time would fall within `k` years given the current point estimate.
|
||||
This is non-parametric (no Gaussian assumption) and directly reflects the
|
||||
model's actual observed error spread, at the cost of being a global (not
|
||||
per-input) uncertainty estimate — every prediction uses the same residual
|
||||
pool, it doesn't widen for "harder" inputs specifically.
|
||||
|
||||
## 6. Features that affect the prediction most
|
||||
|
||||
Channel ablation (zero out one channel, re-predict on the held-out test set,
|
||||
measure the MAE increase) — `channel_ablation_mae_delta` in each bundle:
|
||||
|
||||
| channel | lstm MAE increase | transformer MAE increase |
|
||||
|---|---|---|
|
||||
| **pub** (publications) | **+8.29** | **+8.92** |
|
||||
| pat (patents) | -0.003 (noise) | -0.020 (noise) |
|
||||
| grant (grants) | -0.004 (noise) | -0.020 (noise) |
|
||||
|
||||
**The publication timeline completely dominates.** Removing it destroys the
|
||||
model (MAE jumps from ~0.2 to ~8.5 years — essentially random). Removing
|
||||
patents or grants changes nothing (the tiny negative deltas are noise, not a
|
||||
real effect) — for *this specific task* (predicting how far into a career a
|
||||
founding-like moment falls), patent/grant timing carries no additional signal
|
||||
beyond what publication timing already provides. Practically: if your
|
||||
production pipeline is missing patent/grant year-by-year data for some
|
||||
researchers, this model will still work essentially as well using publication
|
||||
history alone — you do not need to block on having complete patent/grant
|
||||
histories for this specific model (unlike the classifier, where patent/grant
|
||||
*counts* do matter — see `../classifier/README.md` §8).
|
||||
|
||||
## 7. Usage example
|
||||
|
||||
```python
|
||||
from founder_timing_model import FounderTimingModel
|
||||
|
||||
model = FounderTimingModel.load("models/transformer.pt")
|
||||
|
||||
result = model.predict(
|
||||
pub_counts_by_year={2016: 1, 2017: 2, 2018: 3, 2019: 2, 2020: 4, 2021: 3, 2022: 5},
|
||||
pat_counts_by_year={2021: 1},
|
||||
grant_counts_by_year={2020: 1},
|
||||
first_publication_year=2016,
|
||||
as_of_year=2022,
|
||||
)
|
||||
print(result)
|
||||
```
|
||||
|
||||
## 8. Caveats
|
||||
|
||||
- **Founders-only training data.** These models were trained exclusively on
|
||||
people who eventually founded a company, predicting *when in their career*
|
||||
that happened. There is no matched non-founder sequence in the source data
|
||||
(see `experiments/README.md` "Sequence modeling" for why), so this model
|
||||
cannot tell you whether someone will found at all — only, conditional on a
|
||||
founding-like pattern existing, how far into the career it falls. Combine
|
||||
with the classifier (`../classifier/README.md`) for the "will they found at
|
||||
all" question, and this model for "when."
|
||||
- **Retrospective training, prospective use.** Training examples anchor the
|
||||
20-year window at a *real, already-known* founding event. Using the window
|
||||
ending at "now" for someone who hasn't founded yet is a reasonable,
|
||||
intended extrapolation but was not directly validated against real
|
||||
future-unknown outcomes (no ground truth exists yet for currently-active
|
||||
non-founders). Treat `years_to_founding` as a useful signal/ranking tool
|
||||
more than a precise calendar forecast.
|
||||
- **Fixed 20-year window, [1, 20] founding-age range.** See §1.
|
||||
- Reproduce or retrain via `export_sequence_models.py` (depends on the full
|
||||
`experiments/src` research package + `evaluation/datasets_complete`).
|
||||
@@ -1,100 +0,0 @@
|
||||
"""Export the two best founder-timing sequence models (LSTM + Transformer) as
|
||||
standalone production artifacts, with a post-hoc probability layer derived from
|
||||
held-out residuals (see README.md "Probability design" section for rationale).
|
||||
|
||||
Run: conda run -n potential python production/sequence/export_sequence_models.py
|
||||
(from the experiments/ directory)
|
||||
"""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
from src import config, evaluate, sequence_data, sequence_models # noqa: E402
|
||||
|
||||
OUT_DIR = Path(__file__).resolve().parent
|
||||
MODELS_DIR = OUT_DIR / "models"
|
||||
MODELS_DIR.mkdir(exist_ok=True)
|
||||
|
||||
LSTM_KWARGS = {"hidden_size": 64, "num_layers": 1, "dropout": 0.2}
|
||||
TRANSFORMER_KWARGS = {"d_model": 32, "n_heads": 4, "n_layers": 2, "dropout": 0.2}
|
||||
|
||||
|
||||
def channel_ablation(model, X_test, y_test, base_mae):
|
||||
"""Zero out one channel at a time (post-hoc, on the already-fitted model)
|
||||
and measure the MAE increase -- a cheap proxy for channel importance."""
|
||||
rows = {}
|
||||
for c, name in enumerate(sequence_data.CHANNELS):
|
||||
X_ablated = X_test.copy()
|
||||
X_ablated[:, :, c] = 0.0
|
||||
pred = model.predict(X_ablated)
|
||||
metrics = evaluate.regression_metrics(y_test, pred)
|
||||
rows[name] = metrics["mae"] - base_mae
|
||||
return rows
|
||||
|
||||
|
||||
def build_and_export(model_key, model_cls, net_kwargs, X_train, y_train, X_test, y_test, X_all, y_all):
|
||||
print(f"\n=== {model_key} ===")
|
||||
# 1) Fit on train only -> honest held-out metrics + residuals + channel ablation.
|
||||
model = model_cls(**net_kwargs)
|
||||
model.fit(X_train, y_train)
|
||||
pred_test = model.predict(X_test)
|
||||
metrics = evaluate.regression_metrics(y_test, pred_test)
|
||||
residuals = (y_test - pred_test).astype(np.float32)
|
||||
print(f" held-out: MAE={metrics['mae']:.3f} RMSE={metrics['rmse']:.3f} R2={metrics['r2']:.3f}")
|
||||
|
||||
ablation = channel_ablation(model, X_test, y_test, metrics["mae"])
|
||||
print(" channel ablation (MAE increase when channel is zeroed out):")
|
||||
for ch, delta in sorted(ablation.items(), key=lambda kv: -kv[1]):
|
||||
print(f" {ch:6s} +{delta:.4f} MAE")
|
||||
|
||||
# 2) Refit on ALL data for the final shipped artifact (standard practice;
|
||||
# generalization already validated above).
|
||||
final_model = model_cls(**net_kwargs)
|
||||
final_model.fit(X_all, y_all)
|
||||
|
||||
bundle = {
|
||||
"model_key": model_key,
|
||||
"net_kwargs": net_kwargs,
|
||||
"state_dict": final_model.model_.state_dict(),
|
||||
"scaler_mean": final_model.scaler_.mean_,
|
||||
"scaler_std": final_model.scaler_.std_,
|
||||
"window": sequence_data.WINDOW,
|
||||
"channels": sequence_data.CHANNELS,
|
||||
"held_out_metrics": metrics,
|
||||
"held_out_residuals": residuals,
|
||||
"channel_ablation_mae_delta": ablation,
|
||||
}
|
||||
out_path = MODELS_DIR / f"{model_key}.pt"
|
||||
torch.save(bundle, out_path)
|
||||
print(f" saved {out_path} ({out_path.stat().st_size / 1024:.0f} KB)")
|
||||
return metrics, residuals, ablation
|
||||
|
||||
|
||||
def main():
|
||||
print("Building founder-only sequence dataset...")
|
||||
sequences, founding_age, meta = sequence_data.build_founder_sequence_dataset()
|
||||
|
||||
idx = np.arange(len(sequences))
|
||||
idx_train, idx_test = train_test_split(idx, test_size=0.2, random_state=config.RANDOM_STATE)
|
||||
X_train, X_test = sequences[idx_train], sequences[idx_test]
|
||||
y_train, y_test = founding_age[idx_train], founding_age[idx_test]
|
||||
|
||||
results = {}
|
||||
results["lstm"] = build_and_export(
|
||||
"lstm", sequence_models.LSTMRegressor, LSTM_KWARGS,
|
||||
X_train, y_train, X_test, y_test, sequences, founding_age,
|
||||
)
|
||||
results["transformer"] = build_and_export(
|
||||
"transformer", sequence_models.TransformerRegressor, TRANSFORMER_KWARGS,
|
||||
X_train, y_train, X_test, y_test, sequences, founding_age,
|
||||
)
|
||||
|
||||
print("\nDone. Shipped: lstm.pt, transformer.pt")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,192 +0,0 @@
|
||||
"""Self-contained inference wrapper for the founder-timing sequence models
|
||||
(LSTM / Transformer). Depends only on torch/numpy -- no dependency on the
|
||||
`experiments/src` research package.
|
||||
|
||||
These models predict `founding_age`: how many years into a researcher's
|
||||
publishing career a founding event falls, given their chronological
|
||||
publication/patent/grant activity in the WINDOW (20) years up to and including
|
||||
the reference point of interest ("now", if you're asking "how founding-ready
|
||||
does this person look today").
|
||||
|
||||
Usage:
|
||||
from founder_timing_model import FounderTimingModel
|
||||
|
||||
model = FounderTimingModel.load("models/transformer.pt")
|
||||
result = model.predict(
|
||||
pub_counts_by_year={2015: 2, 2016: 3, 2017: 1, 2020: 4, 2022: 2},
|
||||
pat_counts_by_year={2021: 1},
|
||||
grant_counts_by_year={2019: 1},
|
||||
first_publication_year=2015,
|
||||
as_of_year=2023,
|
||||
)
|
||||
print(result)
|
||||
|
||||
See README.md in this directory for the full input schema, output format and
|
||||
the "probability" design rationale.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from torch import nn
|
||||
|
||||
CHANNELS = ["pub", "pat", "grant"]
|
||||
WINDOW = 20
|
||||
DEFAULT_HORIZONS = (1, 2, 3, 5)
|
||||
|
||||
|
||||
class _LSTMNet(nn.Module):
|
||||
"""Must stay structurally identical to src/sequence_models.py::_LSTMNet --
|
||||
state_dict keys are loaded directly from the exported bundle."""
|
||||
|
||||
def __init__(self, n_channels, hidden_size=64, num_layers=1, dropout=0.2):
|
||||
super().__init__()
|
||||
self.lstm = nn.LSTM(
|
||||
input_size=n_channels, hidden_size=hidden_size, num_layers=num_layers,
|
||||
batch_first=True, dropout=dropout if num_layers > 1 else 0.0,
|
||||
)
|
||||
self.head = nn.Sequential(nn.Dropout(dropout), nn.Linear(hidden_size, 1))
|
||||
|
||||
def forward(self, x):
|
||||
_, (h_n, _) = self.lstm(x)
|
||||
return self.head(h_n[-1]).squeeze(-1)
|
||||
|
||||
|
||||
class _TransformerNet(nn.Module):
|
||||
"""Must stay structurally identical to src/sequence_models.py::_TransformerNet."""
|
||||
|
||||
def __init__(self, n_channels, seq_len, d_model=32, n_heads=4, n_layers=2, dropout=0.2):
|
||||
super().__init__()
|
||||
self.input_proj = nn.Linear(n_channels, d_model)
|
||||
self.pos_embedding = nn.Parameter(torch.zeros(1, seq_len, d_model))
|
||||
encoder_layer = nn.TransformerEncoderLayer(
|
||||
d_model=d_model, nhead=n_heads, dim_feedforward=d_model * 4,
|
||||
dropout=dropout, batch_first=True,
|
||||
)
|
||||
self.encoder = nn.TransformerEncoder(encoder_layer, num_layers=n_layers)
|
||||
self.head = nn.Sequential(nn.Dropout(dropout), nn.Linear(d_model, 1))
|
||||
|
||||
def forward(self, x):
|
||||
h = self.input_proj(x) + self.pos_embedding
|
||||
h = self.encoder(h)
|
||||
pooled = h.mean(dim=1)
|
||||
return self.head(pooled).squeeze(-1)
|
||||
|
||||
|
||||
class FounderTimingModel:
|
||||
def __init__(self, bundle: dict[str, Any]):
|
||||
self.model_key: str = bundle["model_key"]
|
||||
self.window: int = bundle["window"]
|
||||
self.channels: list[str] = bundle["channels"]
|
||||
self.scaler_mean = bundle["scaler_mean"]
|
||||
self.scaler_std = bundle["scaler_std"]
|
||||
self.held_out_metrics: dict = bundle["held_out_metrics"]
|
||||
self.held_out_residuals: np.ndarray = bundle["held_out_residuals"]
|
||||
self.channel_ablation_mae_delta: dict = bundle["channel_ablation_mae_delta"]
|
||||
|
||||
n_channels = len(self.channels)
|
||||
if self.model_key == "lstm":
|
||||
self._net = _LSTMNet(n_channels, **bundle["net_kwargs"])
|
||||
elif self.model_key == "transformer":
|
||||
self._net = _TransformerNet(n_channels, self.window, **bundle["net_kwargs"])
|
||||
else:
|
||||
raise ValueError(f"unknown model_key {self.model_key!r}")
|
||||
self._net.load_state_dict(bundle["state_dict"])
|
||||
self._net.eval()
|
||||
|
||||
@classmethod
|
||||
def load(cls, path: str | Path) -> "FounderTimingModel":
|
||||
return cls(torch.load(path, map_location="cpu", weights_only=False))
|
||||
|
||||
# -- building the input sequence ----------------------------------------
|
||||
def build_sequence(
|
||||
self,
|
||||
pub_counts_by_year: dict[int, int] | None = None,
|
||||
pat_counts_by_year: dict[int, int] | None = None,
|
||||
grant_counts_by_year: dict[int, int] | None = None,
|
||||
as_of_year: int | None = None,
|
||||
) -> np.ndarray:
|
||||
"""Turn per-year activity counts into the (WINDOW, 3) chronological,
|
||||
log1p-transformed array the model expects (oldest year first, ending
|
||||
at `as_of_year`). Years with no recorded activity default to 0; years
|
||||
before the start of the available history are zero-padded on the left
|
||||
(identical in spirit to how a founder with < WINDOW years of real
|
||||
pre-founding history looks in the training data)."""
|
||||
pub_counts_by_year = pub_counts_by_year or {}
|
||||
pat_counts_by_year = pat_counts_by_year or {}
|
||||
grant_counts_by_year = grant_counts_by_year or {}
|
||||
if as_of_year is None:
|
||||
all_years = list(pub_counts_by_year) + list(pat_counts_by_year) + list(grant_counts_by_year)
|
||||
if not all_years:
|
||||
raise ValueError("as_of_year must be given if no activity years are provided")
|
||||
as_of_year = max(all_years)
|
||||
|
||||
years = range(as_of_year - self.window + 1, as_of_year + 1) # oldest -> newest, length WINDOW
|
||||
channel_dicts = [pub_counts_by_year, pat_counts_by_year, grant_counts_by_year]
|
||||
seq = np.zeros((self.window, len(self.channels)), dtype=np.float32)
|
||||
for c, counts in enumerate(channel_dicts):
|
||||
for t, year in enumerate(years):
|
||||
seq[t, c] = max(0.0, float(counts.get(year, 0)))
|
||||
return np.log1p(seq)
|
||||
|
||||
# -- prediction -----------------------------------------------------------
|
||||
def _predict_point(self, sequence: np.ndarray) -> np.ndarray:
|
||||
"""`sequence`: (WINDOW, 3) or (n, WINDOW, 3) raw (log1p'd) array."""
|
||||
X = np.asarray(sequence, dtype=np.float32)
|
||||
if X.ndim == 2:
|
||||
X = X[None, ...]
|
||||
X = (X - self.scaler_mean) / self.scaler_std
|
||||
with torch.no_grad():
|
||||
pred = self._net(torch.tensor(X, dtype=torch.float32)).numpy()
|
||||
return pred
|
||||
|
||||
def residual_cdf(self, x: float) -> float:
|
||||
"""Empirical P(residual <= x) from the held-out test set -- the
|
||||
nonparametric basis for every probability this class reports."""
|
||||
return float(np.mean(self.held_out_residuals <= x))
|
||||
|
||||
def predict(
|
||||
self,
|
||||
pub_counts_by_year: dict[int, int] | None = None,
|
||||
pat_counts_by_year: dict[int, int] | None = None,
|
||||
grant_counts_by_year: dict[int, int] | None = None,
|
||||
first_publication_year: int | None = None,
|
||||
as_of_year: int | None = None,
|
||||
horizons: tuple[int, ...] = DEFAULT_HORIZONS,
|
||||
) -> dict[str, Any]:
|
||||
"""Full prediction for one researcher's history ending at `as_of_year`
|
||||
(defaults to the latest year with any recorded activity).
|
||||
|
||||
Returns:
|
||||
predicted_founding_age: point estimate of "years into career at the
|
||||
hypothetical founding moment defined by `as_of_year`".
|
||||
current_career_age: as_of_year - first_publication_year (if given).
|
||||
years_to_founding: predicted_founding_age - current_career_age; <=0
|
||||
means the current activity profile already looks like a typical
|
||||
founding-moment profile (founding could happen any time now).
|
||||
probability_founds_within: {k: P(founds within k years)} for each
|
||||
horizon in `horizons`, derived from held-out residuals (see README).
|
||||
"""
|
||||
seq = self.build_sequence(pub_counts_by_year, pat_counts_by_year, grant_counts_by_year, as_of_year)
|
||||
founding_age_hat = float(self._predict_point(seq)[0])
|
||||
|
||||
result: dict[str, Any] = {
|
||||
"model": self.model_key,
|
||||
"predicted_founding_age": founding_age_hat,
|
||||
}
|
||||
|
||||
if first_publication_year is not None:
|
||||
if as_of_year is None:
|
||||
all_years = list((pub_counts_by_year or {})) + list((pat_counts_by_year or {})) + list((grant_counts_by_year or {}))
|
||||
as_of_year = max(all_years) if all_years else first_publication_year
|
||||
current_career_age = as_of_year - first_publication_year
|
||||
years_to_founding = founding_age_hat - current_career_age
|
||||
result["current_career_age"] = current_career_age
|
||||
result["years_to_founding"] = years_to_founding
|
||||
result["probability_founds_within"] = {
|
||||
k: round(self.residual_cdf(k - years_to_founding), 4) for k in horizons
|
||||
}
|
||||
return result
|
||||
@@ -1,3 +0,0 @@
|
||||
,0
|
||||
statistic,83.84013605442176
|
||||
p_value,5.3644585148746496e-20
|
||||
|
@@ -1,100 +0,0 @@
|
||||
feature,importance_mean,importance_std
|
||||
publications,0.4440974603875724,0.009511785737132612
|
||||
pub_citation_sum,0.0641745019900897,0.0023847457046495867
|
||||
last_patent_year,0.061419305752316286,0.0032168477466114997
|
||||
i10-index,0.052808315628195955,0.002509050818671705
|
||||
pub_citation_mean,0.042499292031831906,0.002523272278649042
|
||||
g-index,0.036249565551782555,0.002265360125324732
|
||||
activities_total,0.03186015042559469,0.001859142044274061
|
||||
pat_citation_mean,0.023747584504377334,0.0018054623744417433
|
||||
grants,0.014545800960367655,0.001636080338818295
|
||||
first_publication_year,0.01341695838784518,0.0011208069436919059
|
||||
last_publication_year,0.010105477585606454,0.001265829119215705
|
||||
patents,0.009386919235293584,0.000828161224172823
|
||||
last_grant_year,0.0061119416876279035,0.0006396038493956664
|
||||
publication_research_area_32,0.005199808047404142,0.0006411887411683997
|
||||
h-index,0.004761111131916573,0.0006185755476381059
|
||||
pat_citation_sum,0.004029264901793272,0.0006407043313268342
|
||||
affiliations,0.003924122102600141,0.0006734435898464144
|
||||
industry_collab_papers,0.002771785899856466,0.000458393950826596
|
||||
first_grant_year,0.0024780107524362215,0.00045174085545348724
|
||||
linked_patents_to_publications,0.0017714854471442888,0.00038735536489506483
|
||||
grant_research_impact,0.0017419551968919865,0.0007783860555244073
|
||||
publication_research_area_31,0.0010347728515872068,0.0004380600676750018
|
||||
publication_research_area_46,0.0010296404274699467,0.00027494253110439427
|
||||
institution_stanford,0.0009637600715686423,0.00023666778366864807
|
||||
patent_research_area_46,0.0007991644733361059,0.0003005059902911959
|
||||
grant_research_area_32,0.0006102226280733592,0.0003698845134606399
|
||||
institution_berkeley,0.00045373766528075123,0.00021951745011740962
|
||||
institution_muenchen,0.0004130569816417906,7.580252297057787e-05
|
||||
patent_research_area_32,0.00036940421614752863,0.00011610246817244868
|
||||
publication_research_area_35,0.0003162362804154439,0.00017402147914398575
|
||||
publication_research_area_42,0.00029062839366878477,0.00015928133313129265
|
||||
institution_oxford,0.0002602274221759626,0.000185358155946732
|
||||
first_patent_year,0.0002299601664907669,0.00015372021880899557
|
||||
institution_telaviv,0.00022185659229883025,0.0002808557319380741
|
||||
institution_harvard,0.00022091161950384407,0.00018883040518073856
|
||||
patent_research_area_35,0.00017105334272454753,0.00013583506288295137
|
||||
publication_research_area_51,0.0001581465869737786,0.00013922623521323216
|
||||
grant_innovation_impact,0.00013702479636796828,0.0001422675814029339
|
||||
institution_ude,0.00013034268850643517,5.51579297443134e-05
|
||||
publication_research_area_33,0.00011963406695062462,9.734481095501337e-05
|
||||
publication_research_area_40,6.163246509007791e-05,8.342838939511106e-05
|
||||
grant_research_area_46,5.6425844484753186e-05,6.057990043771272e-05
|
||||
grant_research_area_42,5.4768959582357504e-05,0.0001321879842622329
|
||||
publication_research_area_44,4.6328393106159774e-05,4.109464765116167e-05
|
||||
institution_toronto,4.203267111526077e-05,0.00013829259973950555
|
||||
grant_research_area_34,3.648946572037404e-05,9.856576928560712e-05
|
||||
publication_research_area_49,3.523595518664657e-05,1.0020003875083567e-05
|
||||
publication_research_area_52,2.8243411024614362e-05,6.365046136625705e-05
|
||||
grant_research_area_52,2.4976831800399558e-05,6.0461267957791294e-05
|
||||
publication_research_area_39,2.2444089520501364e-05,5.4003334909501585e-05
|
||||
publication_research_area_47,2.080080050642641e-05,2.1829610866522595e-05
|
||||
patent_research_area_34,1.2265010515000175e-05,3.4309040012788196e-06
|
||||
publication_research_area_34,1.0963870610469772e-05,5.079619737042506e-05
|
||||
publication_research_area_37,9.739396381164278e-06,1.5473891954426686e-05
|
||||
grant_research_area_31,9.05566937272062e-06,1.2355287634925927e-05
|
||||
grant_research_area_33,7.176496559663237e-06,1.1600418122926559e-05
|
||||
publication_research_area_36,6.871129506863527e-06,1.8889049455628318e-05
|
||||
publication_research_area_50,6.313148147923942e-06,8.093717579945578e-06
|
||||
patent_research_area_41,5.268894264148782e-06,1.4185767546691009e-05
|
||||
grant_research_area_36,3.979969424106055e-06,8.741862922562177e-06
|
||||
grant_research_area_51,2.6849918500770897e-06,7.727353969929902e-05
|
||||
grant_research_area_39,2.6844415874804907e-06,4.9698681231697676e-06
|
||||
patent_research_area_42,2.018322524721672e-06,4.003947557053808e-06
|
||||
patent_research_area_n.,1.5509887295039881e-06,2.7724586593788047e-05
|
||||
grant_research_area_35,2.794525058302799e-07,2.2550590120034133e-06
|
||||
patent_research_area_30,1.1961448171393662e-07,6.938865295073371e-07
|
||||
grant_research_area_47,0.0,0.0
|
||||
publication_research_area_43,0.0,0.0
|
||||
grant_research_area_43,0.0,0.0
|
||||
patent_research_area_33,0.0,0.0
|
||||
grant_research_area_38,0.0,0.0
|
||||
grant_research_area_37,0.0,0.0
|
||||
patent_research_area_37,0.0,0.0
|
||||
patent_research_area_36,0.0,0.0
|
||||
grant_research_area_49,0.0,0.0
|
||||
patent_research_area_38,0.0,0.0
|
||||
grant_research_area_30,0.0,0.0
|
||||
patent_research_area_52,0.0,0.0
|
||||
patent_research_area_50,0.0,0.0
|
||||
patent_research_area_49,0.0,0.0
|
||||
patent_research_area_48,0.0,0.0
|
||||
patent_research_area_47,0.0,0.0
|
||||
patent_research_area_39,0.0,0.0
|
||||
patent_research_area_44,0.0,0.0
|
||||
patent_research_area_43,0.0,0.0
|
||||
grant_research_area_48,0.0,0.0
|
||||
publication_research_area_48,-4.777574768688453e-07,2.5399584991121672e-06
|
||||
grant_research_area_44,-2.6545860416726797e-06,8.853044030928573e-07
|
||||
grant_research_area_40,-3.5805367832819624e-06,1.3088192634427606e-05
|
||||
publication_research_area_41,-4.670934500378143e-06,1.529003843001235e-05
|
||||
patent_research_area_51,-5.39510398220866e-06,6.7771380831518544e-06
|
||||
grant_research_area_50,-6.018075757896479e-06,3.415361829511047e-06
|
||||
publication_research_area_n.,-1.6678560361260698e-05,4.85699334820089e-05
|
||||
patent_research_area_40,-2.2966722354866854e-05,2.624449457092434e-05
|
||||
publication_research_area_30,-2.759677706088981e-05,4.2392146152842375e-05
|
||||
grant_research_area_41,-7.746870943114436e-05,4.853083326762734e-05
|
||||
patent_research_area_31,-7.858662076178912e-05,2.6338982228252595e-05
|
||||
publication_research_area_38,-0.00010061127127826141,6.048638875532882e-05
|
||||
grant_research_area_n.,-0.00018513837033415915,0.00010988699811737849
|
||||
|
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 57 KiB |
@@ -1,25 +0,0 @@
|
||||
held_out_institution,model,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
berkeley,random_forest,0.8938080495356037,0.8561034761519806,0.8651960784313726,0.8606257618854124,0.9508687988322615,0.9352701725889087,0.7748863967212042,0.0916010325285079
|
||||
berkeley,xgboost,0.9352941176470588,0.9163248564397046,0.9125816993464052,0.9144494474007367,0.9782380798780129,0.9728371029060612,0.8624255919906876,0.05184710770845413
|
||||
berkeley,lightgbm,0.9402476780185759,0.9242798353909465,0.9174836601307189,0.9208692086920869,0.981150910015053,0.9755184511242864,0.8728875867367218,0.04690752230798288
|
||||
harvard,random_forest,0.8987654320987655,0.9052183173588925,0.7805325987144169,0.8382642998027613,0.9526397485697599,0.9290937209525628,0.7696254787865199,0.08178858160630093
|
||||
harvard,xgboost,0.9395061728395062,0.9425173439048563,0.8732782369146006,0.9065776930409915,0.9807783681880297,0.9706333807958668,0.8633170529628762,0.04677882418036461
|
||||
harvard,lightgbm,0.9398148148148148,0.9461077844311377,0.8705234159779615,0.9067431850789096,0.9826362607521476,0.9734330946079244,0.8640565194125395,0.043685045783186834
|
||||
muenchen,random_forest,0.7953757225433526,0.6064139941690962,0.832,0.7015177065767285,0.8767349593495936,0.7765094185861298,0.5675742666446973,0.15746290406976293
|
||||
muenchen,xgboost,0.7884393063583816,0.6012084592145015,0.796,0.685025817555938,0.8628682926829269,0.763287320123835,0.542216159841516,0.1559271514415741
|
||||
muenchen,lightgbm,0.7722543352601156,0.581039755351682,0.76,0.658578856152513,0.853691056910569,0.7517422512407861,0.5022355737952905,0.15695599279447855
|
||||
oxford,random_forest,0.911386593204775,0.8539898132427843,0.8245901639344262,0.8390325271059216,0.959453412512546,0.9238390784736245,0.7781516198820395,0.07865284747427456
|
||||
oxford,xgboost,0.9504132231404959,0.9183333333333333,0.9032786885245901,0.9107438016528926,0.984900886584142,0.9722281536725682,0.8764751247733411,0.042194340378046036
|
||||
oxford,lightgbm,0.9554637281910009,0.9253731343283582,0.9147540983606557,0.920032976092333,0.9877645115423219,0.976680741461625,0.8892006068129127,0.03689864957054344
|
||||
stanford,random_forest,0.9001419782300047,0.912889935256033,0.8498630136986302,0.880249716231555,0.9613942820628392,0.9572731678928575,0.7963001054601905,0.08187944047855213
|
||||
stanford,xgboost,0.9245149077141505,0.9096844396082698,0.9161643835616439,0.9129129129129129,0.9797777181881978,0.9772211505881503,0.846320011438327,0.05441083386540413
|
||||
stanford,lightgbm,0.927117841930904,0.9138025095471904,0.9178082191780822,0.9158009841443412,0.9798291807637229,0.9769930836860543,0.8515608804568686,0.053898616481872476
|
||||
telaviv,random_forest,0.9329221279876638,0.9143730886850153,0.9507154213036566,0.9321901792673422,0.9814694934455415,0.9840855248253557,0.8665222579580186,0.06278409820550628
|
||||
telaviv,xgboost,0.9498843484965305,0.9338461538461539,0.9650238473767886,0.9491790461297889,0.9915843987700276,0.9928955188919398,0.9002477352802948,0.035886093974113464
|
||||
telaviv,lightgbm,0.9568234387047032,0.9428129829984544,0.9697933227344993,0.9561128526645768,0.992805327342136,0.9938473761123844,0.9139930650897162,0.03212358373132753
|
||||
toronto,random_forest,0.8310708898944194,0.7942857142857143,0.6465116279069767,0.7128205128205128,0.8714571220930232,0.8089004180527387,0.6012626875361187,0.13535280288698756
|
||||
toronto,xgboost,0.8144796380090498,0.8006535947712419,0.5697674418604651,0.6657608695652174,0.8658689784053156,0.8011683092591997,0.5573915163186545,0.13123539090156555
|
||||
toronto,lightgbm,0.8076923076923077,0.7986348122866894,0.5441860465116279,0.6473029045643154,0.8486399501661129,0.7789467464984129,0.5396833164956024,0.14120805997827313
|
||||
ude,random_forest,0.9242424242424242,0.6923076923076923,0.9,0.782608695652174,0.9624999999999999,0.8845213408920609,0.7469892572492464,0.08766724613880275
|
||||
ude,xgboost,0.9318181818181818,0.7037037037037037,0.95,0.8085106382978723,0.978125,0.9280225174865269,0.780952380952381,0.05495387688279152
|
||||
ude,lightgbm,0.946969696969697,0.76,0.95,0.8444444444444444,0.9870535714285714,0.9470631781805057,0.8203096227459236,0.04920439998805263
|
||||
|
@@ -1,26 +0,0 @@
|
||||
| | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:------------------------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|----------:|
|
||||
| ('berkeley', 'random_forest') | 0.893808 | 0.856103 | 0.865196 | 0.860626 | 0.950869 | 0.93527 | 0.774886 | 0.091601 |
|
||||
| ('berkeley', 'xgboost') | 0.935294 | 0.916325 | 0.912582 | 0.914449 | 0.978238 | 0.972837 | 0.862426 | 0.0518471 |
|
||||
| ('berkeley', 'lightgbm') | 0.940248 | 0.92428 | 0.917484 | 0.920869 | 0.981151 | 0.975518 | 0.872888 | 0.0469075 |
|
||||
| ('harvard', 'random_forest') | 0.898765 | 0.905218 | 0.780533 | 0.838264 | 0.95264 | 0.929094 | 0.769625 | 0.0817886 |
|
||||
| ('harvard', 'xgboost') | 0.939506 | 0.942517 | 0.873278 | 0.906578 | 0.980778 | 0.970633 | 0.863317 | 0.0467788 |
|
||||
| ('harvard', 'lightgbm') | 0.939815 | 0.946108 | 0.870523 | 0.906743 | 0.982636 | 0.973433 | 0.864057 | 0.043685 |
|
||||
| ('muenchen', 'random_forest') | 0.795376 | 0.606414 | 0.832 | 0.701518 | 0.876735 | 0.776509 | 0.567574 | 0.157463 |
|
||||
| ('muenchen', 'xgboost') | 0.788439 | 0.601208 | 0.796 | 0.685026 | 0.862868 | 0.763287 | 0.542216 | 0.155927 |
|
||||
| ('muenchen', 'lightgbm') | 0.772254 | 0.58104 | 0.76 | 0.658579 | 0.853691 | 0.751742 | 0.502236 | 0.156956 |
|
||||
| ('oxford', 'random_forest') | 0.911387 | 0.85399 | 0.82459 | 0.839033 | 0.959453 | 0.923839 | 0.778152 | 0.0786528 |
|
||||
| ('oxford', 'xgboost') | 0.950413 | 0.918333 | 0.903279 | 0.910744 | 0.984901 | 0.972228 | 0.876475 | 0.0421943 |
|
||||
| ('oxford', 'lightgbm') | 0.955464 | 0.925373 | 0.914754 | 0.920033 | 0.987765 | 0.976681 | 0.889201 | 0.0368986 |
|
||||
| ('stanford', 'random_forest') | 0.900142 | 0.91289 | 0.849863 | 0.88025 | 0.961394 | 0.957273 | 0.7963 | 0.0818794 |
|
||||
| ('stanford', 'xgboost') | 0.924515 | 0.909684 | 0.916164 | 0.912913 | 0.979778 | 0.977221 | 0.84632 | 0.0544108 |
|
||||
| ('stanford', 'lightgbm') | 0.927118 | 0.913803 | 0.917808 | 0.915801 | 0.979829 | 0.976993 | 0.851561 | 0.0538986 |
|
||||
| ('telaviv', 'random_forest') | 0.932922 | 0.914373 | 0.950715 | 0.93219 | 0.981469 | 0.984086 | 0.866522 | 0.0627841 |
|
||||
| ('telaviv', 'xgboost') | 0.949884 | 0.933846 | 0.965024 | 0.949179 | 0.991584 | 0.992896 | 0.900248 | 0.0358861 |
|
||||
| ('telaviv', 'lightgbm') | 0.956823 | 0.942813 | 0.969793 | 0.956113 | 0.992805 | 0.993847 | 0.913993 | 0.0321236 |
|
||||
| ('toronto', 'random_forest') | 0.831071 | 0.794286 | 0.646512 | 0.712821 | 0.871457 | 0.8089 | 0.601263 | 0.135353 |
|
||||
| ('toronto', 'xgboost') | 0.81448 | 0.800654 | 0.569767 | 0.665761 | 0.865869 | 0.801168 | 0.557392 | 0.131235 |
|
||||
| ('toronto', 'lightgbm') | 0.807692 | 0.798635 | 0.544186 | 0.647303 | 0.84864 | 0.778947 | 0.539683 | 0.141208 |
|
||||
| ('ude', 'random_forest') | 0.924242 | 0.692308 | 0.9 | 0.782609 | 0.9625 | 0.884521 | 0.746989 | 0.0876672 |
|
||||
| ('ude', 'xgboost') | 0.931818 | 0.703704 | 0.95 | 0.808511 | 0.978125 | 0.928023 | 0.780952 | 0.0549539 |
|
||||
| ('ude', 'lightgbm') | 0.94697 | 0.76 | 0.95 | 0.844444 | 0.987054 | 0.947063 | 0.82031 | 0.0492044 |
|
||||
@@ -1,13 +0,0 @@
|
||||
model,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
lightgbm,0.9296756592906942,0.913372582001682,0.8938271604938272,0.9034941763727121,0.976269322211954,0.9685049361518786,0.8483100198135644,0.053432731044197566
|
||||
stacking_ensemble,0.9269475598666262,0.8965798045602605,0.9061728395061729,0.9013507981989357,0.9754794515137872,0.9675765397034317,0.8433811094467112,0.05719178794634457
|
||||
xgboost,0.9269475598666262,0.907190635451505,0.8930041152263375,0.9000414765657404,0.9744139159419603,0.9665730556966816,0.8425529635211692,0.05556803196668625
|
||||
catboost,0.9224007274931798,0.9026028547439127,0.8847736625514403,0.8935993349958438,0.971654897593264,0.9632567246873249,0.8326428131667227,0.059948209000983244
|
||||
torch_mlp,0.9196726280691119,0.8984899328859061,0.8814814814814815,0.8899044453676777,0.9622309502934369,0.955302995455666,0.8267763485833509,0.06462439894676208
|
||||
random_forest,0.8957259775689603,0.8731790916880892,0.8386831275720165,0.855583543240974,0.951964210958666,0.9349680824025975,0.7744264740411075,0.08763717778689288
|
||||
logistic_regression,0.881782358290391,0.8235294117647058,0.8641975308641975,0.8433734939759037,0.9434869236905918,0.9275477315216814,0.7490861135477721,0.08788246377799803
|
||||
svm_rbf,0.8754167929675659,0.845360824742268,0.8098765432098766,0.8272383354350568,0.9373219828914007,0.9143562404019991,0.7303022058858781,0.09180799832693237
|
||||
decision_tree,0.8375265231888451,0.7379117028731604,0.8666666666666667,0.7971233913701741,0.9210842160138386,0.8829334748606221,0.6690488462111767,0.10435262951516595
|
||||
knn,0.8184298272203698,0.8162217659137577,0.654320987654321,0.7263590680676107,0.880971619945815,0.8208621350700424,0.6010655862759007,0.13055538715435655
|
||||
gaussian_nb,0.7241588360109124,0.8056112224448898,0.3308641975308642,0.4690781796966161,0.8162221669312734,0.7211454455622044,0.3827487061238318,0.2730256049045907
|
||||
dummy_most_frequent,0.6317065777508336,0.0,0.0,0.0,0.5,0.3682934222491664,0.0,0.3682934222491664
|
||||
|
@@ -1,14 +0,0 @@
|
||||
| model | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:--------------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|----------:|
|
||||
| lightgbm | 0.929676 | 0.913373 | 0.893827 | 0.903494 | 0.976269 | 0.968505 | 0.84831 | 0.0534327 |
|
||||
| stacking_ensemble | 0.926948 | 0.89658 | 0.906173 | 0.901351 | 0.975479 | 0.967577 | 0.843381 | 0.0571918 |
|
||||
| xgboost | 0.926948 | 0.907191 | 0.893004 | 0.900041 | 0.974414 | 0.966573 | 0.842553 | 0.055568 |
|
||||
| catboost | 0.922401 | 0.902603 | 0.884774 | 0.893599 | 0.971655 | 0.963257 | 0.832643 | 0.0599482 |
|
||||
| torch_mlp | 0.919673 | 0.89849 | 0.881481 | 0.889904 | 0.962231 | 0.955303 | 0.826776 | 0.0646244 |
|
||||
| random_forest | 0.895726 | 0.873179 | 0.838683 | 0.855584 | 0.951964 | 0.934968 | 0.774426 | 0.0876372 |
|
||||
| logistic_regression | 0.881782 | 0.823529 | 0.864198 | 0.843373 | 0.943487 | 0.927548 | 0.749086 | 0.0878825 |
|
||||
| svm_rbf | 0.875417 | 0.845361 | 0.809877 | 0.827238 | 0.937322 | 0.914356 | 0.730302 | 0.091808 |
|
||||
| decision_tree | 0.837527 | 0.737912 | 0.866667 | 0.797123 | 0.921084 | 0.882933 | 0.669049 | 0.104353 |
|
||||
| knn | 0.81843 | 0.816222 | 0.654321 | 0.726359 | 0.880972 | 0.820862 | 0.601066 | 0.130555 |
|
||||
| gaussian_nb | 0.724159 | 0.805611 | 0.330864 | 0.469078 | 0.816222 | 0.721145 | 0.382749 | 0.273026 |
|
||||
| dummy_most_frequent | 0.631707 | 0 | 0 | 0 | 0.5 | 0.368293 | 0 | 0.368293 |
|
||||
@@ -1,3 +0,0 @@
|
||||
pipeline,n_rows,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
fix_on,16494,0.9296756592906942,0.913372582001682,0.8938271604938272,0.9034941763727121,0.976269322211954,0.9685049361518786,0.8483100198135644,0.053432731044197566
|
||||
fix_off,16466,0.8466909532483303,0.7813248204309656,0.8090909090909091,0.7949654892407633,0.9180388556653607,0.8864221631506207,0.672862341314094,0.10965134265264417
|
||||
|
@@ -1,4 +0,0 @@
|
||||
| pipeline | n_rows | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:-----------|---------:|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|----------:|
|
||||
| fix_on | 16494 | 0.929676 | 0.913373 | 0.893827 | 0.903494 | 0.976269 | 0.968505 | 0.84831 | 0.0534327 |
|
||||
| fix_off | 16466 | 0.846691 | 0.781325 | 0.809091 | 0.794965 | 0.918039 | 0.886422 | 0.672862 | 0.109651 |
|
||||
@@ -1,23 +0,0 @@
|
||||
group,n,founder_rate,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
32,1166,0.22384219554030874,0.9493996569468267,0.9316239316239316,0.8352490421455939,0.8808080808080808,0.9666920683304757,0.9364408340780385,0.8508506430002786,0.04368896580612041
|
||||
n.,429,0.662004662004662,0.9230769230769231,0.9225589225589226,0.9647887323943662,0.9432013769363167,0.9841185041282177,0.9924822312137267,0.8262349450003642,0.05463661429743082
|
||||
31,377,0.21750663129973474,0.946949602122016,0.918918918918919,0.8292682926829268,0.8717948717948718,0.9728813559322034,0.9356866199037027,0.8402167428448224,0.04536923541973955
|
||||
40,244,0.47540983606557374,0.9098360655737705,0.8983050847457628,0.9137931034482759,0.905982905982906,0.9617456896551724,0.9642595097786962,0.8194913688077033,0.07957434518007606
|
||||
42,203,0.31527093596059114,0.9261083743842364,0.9016393442622951,0.859375,0.88,0.9769559352517986,0.9637751383174913,0.8271608292650046,0.048779758321450296
|
||||
46,157,0.6942675159235668,0.9171974522292994,0.9528301886792453,0.926605504587156,0.9395348837209302,0.9682721712538226,0.9840532918333846,0.8090948889478105,0.05626512209498496
|
||||
51,133,0.23308270676691728,0.9548872180451128,0.9310344827586207,0.8709677419354839,0.9,0.970271979759646,0.9409363609392009,0.8717228983609421,0.04478101537130266
|
||||
34,120,0.3416666666666667,0.925,0.9210526315789473,0.8536585365853658,0.8860759493670886,0.9771534424205001,0.9650667269791089,0.8316270648620494,0.05246369285584714
|
||||
52,95,0.30526315789473685,0.9578947368421052,0.9310344827586207,0.9310344827586207,0.9310344827586207,0.9937304075235109,0.9883026531846857,0.9007314524555904,0.027603964117175042
|
||||
30,56,0.32142857142857145,0.9821428571428571,1.0,0.9444444444444444,0.9714285714285714,0.9809941520467838,0.9767025089605734,0.9592851089368167,0.0369718805280747
|
||||
37,43,0.5348837209302325,0.8372093023255814,0.9444444444444444,0.7391304347826086,0.8292682926829268,0.9,0.9136438168932886,0.696745366888215,0.15414824132263785
|
||||
35,38,0.7631578947368421,0.8947368421052632,0.9032258064516129,0.9655172413793104,0.9333333333333333,0.9693486590038315,0.9921059585149952,0.6933201520991935,0.07486361338542762
|
||||
41,36,0.4722222222222222,0.9722222222222222,1.0,0.9411764705882353,0.9696969696969697,0.9938080495356038,0.9938080495356038,0.945577943407535,0.032185687482793046
|
||||
44,36,0.5,0.9166666666666666,0.9411764705882353,0.8888888888888888,0.9142857142857143,0.9876543209876543,0.9872494075602952,0.8346223261119858,0.04977443231283995
|
||||
49,32,0.34375,0.96875,0.9166666666666666,1.0,0.9565217391304348,0.9956709956709956,0.9924242424242424,0.9343531843023135,0.03103818954401077
|
||||
39,32,0.5625,0.96875,0.9473684210526315,1.0,0.972972972972973,1.0,1.0,0.9379228369755696,0.02519009805802744
|
||||
38,27,0.6666666666666666,0.7777777777777778,0.8,0.8888888888888888,0.8421052631578947,0.888888888888889,0.9502100840336136,0.4780914437337575,0.1384746732914565
|
||||
50,21,0.38095238095238093,0.9523809523809523,1.0,0.875,0.9333333333333333,1.0,1.0,0.9013878188659973,0.03054786135988341
|
||||
33,16,0.9375,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.015340673169459336
|
||||
47,16,0.625,0.875,0.9,0.9,0.9,0.9666666666666667,0.980909090909091,0.7333333333333333,0.08370998701642743
|
||||
43,10,0.5,0.9,1.0,0.8,0.8888888888888888,0.9600000000000001,0.9666666666666666,0.816496580927726,0.08761755190466188
|
||||
48,7,0.42857142857142855,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0035793736676227616
|
||||
|
@@ -1,24 +0,0 @@
|
||||
| group | n | founder_rate | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:--------|-----:|---------------:|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|-----------:|
|
||||
| 32 | 1166 | 0.223842 | 0.9494 | 0.931624 | 0.835249 | 0.880808 | 0.966692 | 0.936441 | 0.850851 | 0.043689 |
|
||||
| n. | 429 | 0.662005 | 0.923077 | 0.922559 | 0.964789 | 0.943201 | 0.984119 | 0.992482 | 0.826235 | 0.0546366 |
|
||||
| 31 | 377 | 0.217507 | 0.94695 | 0.918919 | 0.829268 | 0.871795 | 0.972881 | 0.935687 | 0.840217 | 0.0453692 |
|
||||
| 40 | 244 | 0.47541 | 0.909836 | 0.898305 | 0.913793 | 0.905983 | 0.961746 | 0.96426 | 0.819491 | 0.0795743 |
|
||||
| 42 | 203 | 0.315271 | 0.926108 | 0.901639 | 0.859375 | 0.88 | 0.976956 | 0.963775 | 0.827161 | 0.0487798 |
|
||||
| 46 | 157 | 0.694268 | 0.917197 | 0.95283 | 0.926606 | 0.939535 | 0.968272 | 0.984053 | 0.809095 | 0.0562651 |
|
||||
| 51 | 133 | 0.233083 | 0.954887 | 0.931034 | 0.870968 | 0.9 | 0.970272 | 0.940936 | 0.871723 | 0.044781 |
|
||||
| 34 | 120 | 0.341667 | 0.925 | 0.921053 | 0.853659 | 0.886076 | 0.977153 | 0.965067 | 0.831627 | 0.0524637 |
|
||||
| 52 | 95 | 0.305263 | 0.957895 | 0.931034 | 0.931034 | 0.931034 | 0.99373 | 0.988303 | 0.900731 | 0.027604 |
|
||||
| 30 | 56 | 0.321429 | 0.982143 | 1 | 0.944444 | 0.971429 | 0.980994 | 0.976703 | 0.959285 | 0.0369719 |
|
||||
| 37 | 43 | 0.534884 | 0.837209 | 0.944444 | 0.73913 | 0.829268 | 0.9 | 0.913644 | 0.696745 | 0.154148 |
|
||||
| 35 | 38 | 0.763158 | 0.894737 | 0.903226 | 0.965517 | 0.933333 | 0.969349 | 0.992106 | 0.69332 | 0.0748636 |
|
||||
| 41 | 36 | 0.472222 | 0.972222 | 1 | 0.941176 | 0.969697 | 0.993808 | 0.993808 | 0.945578 | 0.0321857 |
|
||||
| 44 | 36 | 0.5 | 0.916667 | 0.941176 | 0.888889 | 0.914286 | 0.987654 | 0.987249 | 0.834622 | 0.0497744 |
|
||||
| 49 | 32 | 0.34375 | 0.96875 | 0.916667 | 1 | 0.956522 | 0.995671 | 0.992424 | 0.934353 | 0.0310382 |
|
||||
| 39 | 32 | 0.5625 | 0.96875 | 0.947368 | 1 | 0.972973 | 1 | 1 | 0.937923 | 0.0251901 |
|
||||
| 38 | 27 | 0.666667 | 0.777778 | 0.8 | 0.888889 | 0.842105 | 0.888889 | 0.95021 | 0.478091 | 0.138475 |
|
||||
| 50 | 21 | 0.380952 | 0.952381 | 1 | 0.875 | 0.933333 | 1 | 1 | 0.901388 | 0.0305479 |
|
||||
| 33 | 16 | 0.9375 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0.0153407 |
|
||||
| 47 | 16 | 0.625 | 0.875 | 0.9 | 0.9 | 0.9 | 0.966667 | 0.980909 | 0.733333 | 0.08371 |
|
||||
| 43 | 10 | 0.5 | 0.9 | 1 | 0.8 | 0.888889 | 0.96 | 0.966667 | 0.816497 | 0.0876176 |
|
||||
| 48 | 7 | 0.428571 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0.00357937 |
|
||||
@@ -1,9 +0,0 @@
|
||||
,point_estimate,ci95_low,ci95_high
|
||||
accuracy,0.9366474689299787,0.9284555926038193,0.9451348893604122
|
||||
precision,0.926271186440678,0.9112063996289643,0.9408187198226067
|
||||
recall,0.8995884773662551,0.8825876445799337,0.9156638830280204
|
||||
f1,0.9127348643006263,0.9005372458914456,0.9239454361275332
|
||||
roc_auc,0.9776117074634882,0.9730446608169061,0.9819179575346694
|
||||
pr_auc,0.9705838681584741,0.9647752214620384,0.975897387247084
|
||||
mcc,0.8632522856286617,0.8448324894247283,0.8805182738534791
|
||||
brier,0.05082471982015067,0.045421652957712146,0.05632171601136752
|
||||
|
@@ -1,10 +0,0 @@
|
||||
| | point_estimate | ci95_low | ci95_high |
|
||||
|:----------|-----------------:|-----------:|------------:|
|
||||
| accuracy | 0.936647 | 0.928456 | 0.945135 |
|
||||
| precision | 0.926271 | 0.911206 | 0.940819 |
|
||||
| recall | 0.899588 | 0.882588 | 0.915664 |
|
||||
| f1 | 0.912735 | 0.900537 | 0.923945 |
|
||||
| roc_auc | 0.977612 | 0.973045 | 0.981918 |
|
||||
| pr_auc | 0.970584 | 0.964775 | 0.975897 |
|
||||
| mcc | 0.863252 | 0.844832 | 0.880518 |
|
||||
| brier | 0.0508247 | 0.0454217 | 0.0563217 |
|
||||
@@ -1,9 +0,0 @@
|
||||
,mean,std,ci95_low,ci95_high
|
||||
accuracy,0.6315629945381027,0.000152607314577894,0.6314292283290328,0.6316967607471726
|
||||
precision,0.0,0.0,0.0,0.0
|
||||
recall,0.0,0.0,0.0,0.0
|
||||
f1,0.0,0.0,0.0,0.0
|
||||
roc_auc,0.5,0.0,0.5,0.5
|
||||
pr_auc,0.3684370054618973,0.000152607314577894,0.36830323925282743,0.36857077167096713
|
||||
mcc,0.0,0.0,0.0,0.0
|
||||
brier,0.3684370054618973,0.000152607314577894,0.36830323925282743,0.36857077167096713
|
||||
|
@@ -1,9 +0,0 @@
|
||||
,mean,std,ci95_low,ci95_high
|
||||
accuracy,0.9301560040521679,0.004832569968831805,0.9259200697092858,0.9343919383950501
|
||||
precision,0.9210205005213952,0.005363091113689678,0.916319543891899,0.9257214571508914
|
||||
recall,0.8864569796404591,0.011327284656886847,0.8765281768710896,0.8963857824098286
|
||||
f1,0.9033804575410747,0.007077308370071776,0.8971769232366968,0.9095839918454525
|
||||
roc_auc,0.9778044083998637,0.002580893205000624,0.9755421557614367,0.9800666610382908
|
||||
pr_auc,0.969958390900661,0.0030785333991232323,0.9672599373996954,0.9726568444016267
|
||||
mcc,0.8491361246489078,0.01056040568851125,0.839879520933029,0.8583927283647865
|
||||
brier,0.05229056699624248,0.002611979994158263,0.05000106558570199,0.05458006840678297
|
||||
|
@@ -1,9 +0,0 @@
|
||||
,mean,std,ci95_low,ci95_high
|
||||
accuracy,0.877833994571007,0.005709536471229038,0.8728293651964915,0.8828386239455225
|
||||
precision,0.8241154301590724,0.008895746233050398,0.8163179647902986,0.8319128955278462
|
||||
recall,0.849927442061945,0.015153152825682954,0.8366451179836104,0.8632097661402797
|
||||
f1,0.8367420177360618,0.008288518311350008,0.8294768111083051,0.8440072243638186
|
||||
roc_auc,0.941702178253095,0.006210328162763004,0.9362585856067633,0.9471457708994266
|
||||
pr_auc,0.922607131065136,0.0063617129672597535,0.9170308437870672,0.9281834183432048
|
||||
mcc,0.7395022800023918,0.012603583626827284,0.7284547518605137,0.75054980814427
|
||||
brier,0.0913441224489286,0.003520196889471585,0.08825853382962423,0.09442971106823297
|
||||
|
@@ -1,9 +0,0 @@
|
||||
,mean,std,ci95_low,ci95_high
|
||||
accuracy,0.8924456590572405,0.00651487700889904,0.8867351175773166,0.8981562005371644
|
||||
precision,0.8727333377136273,0.007422272623764793,0.866227428908992,0.8792392465182626
|
||||
recall,0.829030079055664,0.01844236050077116,0.8128646373315136,0.8451955207798143
|
||||
f1,0.850223748276734,0.010349709747713121,0.8411518276957687,0.8592956688576993
|
||||
roc_auc,0.9527710767910506,0.006542740503664845,0.9470361118811189,0.9585060417009822
|
||||
pr_auc,0.9358309508430764,0.00643481567167842,0.9301905862193713,0.9414713154667815
|
||||
mcc,0.7671314169694046,0.014522057546517971,0.7544022722933108,0.7798605616454983
|
||||
brier,0.08755658794676884,0.0029756638450860926,0.08494830358553487,0.0901648723080028
|
||||
|
@@ -1,6 +0,0 @@
|
||||
,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
dummy_most_frequent,0.6315629945381027,0.0,0.0,0.0,0.5,0.3684370054618973,0.0,0.3684370054618973
|
||||
logistic_regression,0.877833994571007,0.8241154301590724,0.849927442061945,0.8367420177360618,0.941702178253095,0.922607131065136,0.7395022800023918,0.0913441224489286
|
||||
random_forest,0.8924456590572405,0.8727333377136273,0.829030079055664,0.850223748276734,0.9527710767910506,0.9358309508430764,0.7671314169694046,0.08755658794676884
|
||||
xgboost,0.9277916328357951,0.9135406959068092,0.8881029348061512,0.9005883623006266,0.9767097128228892,0.9683117817597591,0.8441820066940338,0.05477161929011345
|
||||
lightgbm,0.9301560040521679,0.9210205005213952,0.8864569796404591,0.9033804575410747,0.9778044083998637,0.969958390900661,0.8491361246489078,0.05229056699624248
|
||||
|
@@ -1,7 +0,0 @@
|
||||
| | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:--------------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|----------:|
|
||||
| dummy_most_frequent | 0.631563 | 0 | 0 | 0 | 0.5 | 0.368437 | 0 | 0.368437 |
|
||||
| logistic_regression | 0.877834 | 0.824115 | 0.849927 | 0.836742 | 0.941702 | 0.922607 | 0.739502 | 0.0913441 |
|
||||
| random_forest | 0.892446 | 0.872733 | 0.82903 | 0.850224 | 0.952771 | 0.935831 | 0.767131 | 0.0875566 |
|
||||
| xgboost | 0.927792 | 0.913541 | 0.888103 | 0.900588 | 0.97671 | 0.968312 | 0.844182 | 0.0547716 |
|
||||
| lightgbm | 0.930156 | 0.921021 | 0.886457 | 0.90338 | 0.977804 | 0.969958 | 0.849136 | 0.0522906 |
|
||||
@@ -1,9 +0,0 @@
|
||||
,mean,std,ci95_low,ci95_high
|
||||
accuracy,0.9277916328357951,0.003551960767446554,0.9246782019498614,0.9309050637217289
|
||||
precision,0.9135406959068092,0.0028831677666106537,0.9110134879330716,0.9160679038805468
|
||||
recall,0.8881029348061512,0.01305781968580872,0.8766572512036331,0.8995486184086693
|
||||
f1,0.9005883623006266,0.005702534790830589,0.8955898701695755,0.9055868544316776
|
||||
roc_auc,0.9767097128228892,0.0033082724285164174,0.9738098841838948,0.9796095414618836
|
||||
pr_auc,0.9683117817597591,0.003612163522900202,0.9651455808320035,0.9714779826875146
|
||||
mcc,0.8441820066940338,0.00794620970622261,0.8372168467879335,0.851147166600134
|
||||
brier,0.05477161929011345,0.0026008881508963405,0.05249184030886049,0.057051398271366405
|
||||
|
@@ -1,15 +0,0 @@
|
||||
area,model,n_train,n_test,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
32,specialist,4721.0,1181,0.930567315834039,0.8629032258064516,0.816793893129771,0.8392156862745098,0.9673267491215974,0.9292015553816835,0.7954692332100317,0.0519155166539892
|
||||
32,pooled_on_subset,,1166,0.9493996569468267,0.9316239316239316,0.8352490421455939,0.8808080808080808,0.9666920683304757,0.9364408340780385,0.8508506430002786,0.04368896580612041
|
||||
31,specialist,1500.0,375,0.9253333333333333,0.8767123287671232,0.7710843373493976,0.8205128205128205,0.952962535071794,0.8952200307899209,0.776160027639481,0.06495098958516522
|
||||
31,pooled_on_subset,,377,0.946949602122016,0.918918918918919,0.8292682926829268,0.8717948717948718,0.9728813559322034,0.9356866199037027,0.8402167428448224,0.04536923541973955
|
||||
40,specialist,1022.0,256,0.83984375,0.8571428571428571,0.8095238095238095,0.8326530612244898,0.9236263736263736,0.9331645942069452,0.6803555888841176,0.12703101416739418
|
||||
40,pooled_on_subset,,244,0.9098360655737705,0.8983050847457628,0.9137931034482759,0.905982905982906,0.9617456896551724,0.9642595097786962,0.8194913688077033,0.07957434518007606
|
||||
42,specialist,775.0,194,0.8969072164948454,0.88,0.7586206896551724,0.8148148148148148,0.9349645030425964,0.8994204511987712,0.7478616876796342,0.08982080462945383
|
||||
42,pooled_on_subset,,203,0.9261083743842364,0.9016393442622951,0.859375,0.88,0.9769559352517986,0.9637751383174913,0.8271608292650046,0.048779758321450296
|
||||
46,specialist,658.0,165,0.9090909090909091,0.9454545454545454,0.9203539823008849,0.9327354260089686,0.9406058543226685,0.9674811594039668,0.7933093260902778,0.08051958369056347
|
||||
46,pooled_on_subset,,157,0.9171974522292994,0.9528301886792453,0.926605504587156,0.9395348837209302,0.9682721712538226,0.9840532918333846,0.8090948889478105,0.05626512209498496
|
||||
51,specialist,513.0,129,0.875968992248062,0.7272727272727273,0.7741935483870968,0.75,0.9186965108624096,0.8476593718423702,0.6682097848250941,0.100902416618966
|
||||
51,pooled_on_subset,,133,0.9548872180451128,0.9310344827586207,0.8709677419354839,0.9,0.970271979759646,0.9409363609392009,0.8717228983609421,0.04478101537130266
|
||||
34,specialist,462.0,116,0.9051724137931034,0.896551724137931,0.7647058823529411,0.8253968253968254,0.9540889526542324,0.9090455749994415,0.765404529471217,0.07917537304289644
|
||||
34,pooled_on_subset,,120,0.925,0.9210526315789473,0.8536585365853658,0.8860759493670886,0.9771534424205001,0.9650667269791089,0.8316270648620494,0.05246369285584714
|
||||
|
@@ -1,16 +0,0 @@
|
||||
| | n_train | n_test | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:---------------------------|----------:|---------:|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|----------:|
|
||||
| ('32', 'specialist') | 4721 | 1181 | 0.930567 | 0.862903 | 0.816794 | 0.839216 | 0.967327 | 0.929202 | 0.795469 | 0.0519155 |
|
||||
| ('32', 'pooled_on_subset') | nan | 1166 | 0.9494 | 0.931624 | 0.835249 | 0.880808 | 0.966692 | 0.936441 | 0.850851 | 0.043689 |
|
||||
| ('31', 'specialist') | 1500 | 375 | 0.925333 | 0.876712 | 0.771084 | 0.820513 | 0.952963 | 0.89522 | 0.77616 | 0.064951 |
|
||||
| ('31', 'pooled_on_subset') | nan | 377 | 0.94695 | 0.918919 | 0.829268 | 0.871795 | 0.972881 | 0.935687 | 0.840217 | 0.0453692 |
|
||||
| ('40', 'specialist') | 1022 | 256 | 0.839844 | 0.857143 | 0.809524 | 0.832653 | 0.923626 | 0.933165 | 0.680356 | 0.127031 |
|
||||
| ('40', 'pooled_on_subset') | nan | 244 | 0.909836 | 0.898305 | 0.913793 | 0.905983 | 0.961746 | 0.96426 | 0.819491 | 0.0795743 |
|
||||
| ('42', 'specialist') | 775 | 194 | 0.896907 | 0.88 | 0.758621 | 0.814815 | 0.934965 | 0.89942 | 0.747862 | 0.0898208 |
|
||||
| ('42', 'pooled_on_subset') | nan | 203 | 0.926108 | 0.901639 | 0.859375 | 0.88 | 0.976956 | 0.963775 | 0.827161 | 0.0487798 |
|
||||
| ('46', 'specialist') | 658 | 165 | 0.909091 | 0.945455 | 0.920354 | 0.932735 | 0.940606 | 0.967481 | 0.793309 | 0.0805196 |
|
||||
| ('46', 'pooled_on_subset') | nan | 157 | 0.917197 | 0.95283 | 0.926606 | 0.939535 | 0.968272 | 0.984053 | 0.809095 | 0.0562651 |
|
||||
| ('51', 'specialist') | 513 | 129 | 0.875969 | 0.727273 | 0.774194 | 0.75 | 0.918697 | 0.847659 | 0.66821 | 0.100902 |
|
||||
| ('51', 'pooled_on_subset') | nan | 133 | 0.954887 | 0.931034 | 0.870968 | 0.9 | 0.970272 | 0.940936 | 0.871723 | 0.044781 |
|
||||
| ('34', 'specialist') | 462 | 116 | 0.905172 | 0.896552 | 0.764706 | 0.825397 | 0.954089 | 0.909046 | 0.765405 | 0.0791754 |
|
||||
| ('34', 'pooled_on_subset') | nan | 120 | 0.925 | 0.921053 | 0.853659 | 0.886076 | 0.977153 | 0.965067 | 0.831627 | 0.0524637 |
|
||||
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 47 KiB |
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"random_forest": {
|
||||
"max_depth": 15,
|
||||
"max_features": 0.4931994274157803,
|
||||
"min_samples_leaf": 1,
|
||||
"n_estimators": 720
|
||||
},
|
||||
"xgboost": {
|
||||
"colsample_bytree": 0.8608647605824367,
|
||||
"learning_rate": 0.05483713475230159,
|
||||
"max_depth": 8,
|
||||
"min_child_weight": 7,
|
||||
"n_estimators": 542,
|
||||
"subsample": 0.8842651558743149
|
||||
},
|
||||
"lightgbm": {
|
||||
"colsample_bytree": 0.9436063712881633,
|
||||
"learning_rate": 0.09972083578077036,
|
||||
"min_child_samples": 41,
|
||||
"n_estimators": 611,
|
||||
"num_leaves": 17,
|
||||
"subsample": 0.9043140194467589
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
model,variant,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
random_forest,default,0.8957259775689603,0.8731790916880892,0.8386831275720165,0.855583543240974,0.951964210958666,0.9349680824025975,0.7744264740411075,0.08763717778689288
|
||||
random_forest,tuned,0.9151257956956653,0.8905597326649958,0.8773662551440329,0.8839137645107794,0.9648383134680854,0.9532390244050343,0.8170865290519,0.06774435426181988
|
||||
xgboost,default,0.9269475598666262,0.907190635451505,0.8930041152263375,0.9000414765657404,0.9744139159419603,0.9665730556966816,0.8425529635211692,0.05556803196668625
|
||||
xgboost,tuned,0.9305850257653835,0.9163851351351351,0.8930041152263375,0.9045435598165903,0.9780860248177374,0.971164830473292,0.8501963188015546,0.05061671882867813
|
||||
lightgbm,default,0.9296756592906942,0.913372582001682,0.8938271604938272,0.9034941763727121,0.976269322211954,0.9685049361518786,0.8483100198135644,0.053432731044197566
|
||||
lightgbm,tuned,0.9366474689299787,0.926271186440678,0.8995884773662551,0.9127348643006263,0.9776117074634882,0.9705838681584741,0.8632522856286617,0.05082471982015067
|
||||
|
@@ -1,8 +0,0 @@
|
||||
| | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:-----------------------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|----------:|
|
||||
| ('random_forest', 'default') | 0.895726 | 0.873179 | 0.838683 | 0.855584 | 0.951964 | 0.934968 | 0.774426 | 0.0876372 |
|
||||
| ('random_forest', 'tuned') | 0.915126 | 0.89056 | 0.877366 | 0.883914 | 0.964838 | 0.953239 | 0.817087 | 0.0677444 |
|
||||
| ('xgboost', 'default') | 0.926948 | 0.907191 | 0.893004 | 0.900041 | 0.974414 | 0.966573 | 0.842553 | 0.055568 |
|
||||
| ('xgboost', 'tuned') | 0.930585 | 0.916385 | 0.893004 | 0.904544 | 0.978086 | 0.971165 | 0.850196 | 0.0506167 |
|
||||
| ('lightgbm', 'default') | 0.929676 | 0.913373 | 0.893827 | 0.903494 | 0.976269 | 0.968505 | 0.84831 | 0.0534327 |
|
||||
| ('lightgbm', 'tuned') | 0.936647 | 0.926271 | 0.899588 | 0.912735 | 0.977612 | 0.970584 | 0.863252 | 0.0508247 |
|
||||
@@ -1,10 +0,0 @@
|
||||
,0
|
||||
initial,16822
|
||||
no_publication_anchor,1430
|
||||
implausible_profile_founders,425
|
||||
implausible_profile_nonfounders,770
|
||||
founder_bad_founding_year,340
|
||||
founder_bad_career_age,723
|
||||
duplicates,0
|
||||
below_min_pubs_at_index_founders,1112
|
||||
below_min_pubs_at_index_nonfounders,3005
|
||||
|
@@ -1,25 +0,0 @@
|
||||
held_out_institution,model,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
berkeley,random_forest,0.7659914712153518,0.5685019206145967,0.8131868131868132,0.6691785983421251,0.8547619047619047,0.7330881372592069,0.5158519325545086,0.16281251622327844
|
||||
berkeley,xgboost,0.7915778251599147,0.6086956521739131,0.7948717948717948,0.6894360603653693,0.8576069294114407,0.741586799531578,0.5475397548573835,0.15189167857170105
|
||||
berkeley,lightgbm,0.7814498933901919,0.603030303030303,0.7289377289377289,0.6600331674958541,0.8499407860310114,0.7350659292472954,0.5059997706165712,0.149555122726439
|
||||
harvard,random_forest,0.8015873015873016,0.5753968253968254,0.6430155210643016,0.6073298429319371,0.8438771689504753,0.6573849413778056,0.4764456796429979,0.13855781340944884
|
||||
harvard,xgboost,0.8317460317460318,0.639412997903564,0.6762749445676275,0.6573275862068966,0.8633058495598539,0.7000843424710989,0.5463194583057209,0.12460028380155563
|
||||
harvard,lightgbm,0.8232804232804233,0.6297117516629712,0.6297117516629712,0.6297117516629712,0.8558049520099724,0.6972393890872501,0.5136589372084889,0.12547720520401978
|
||||
muenchen,random_forest,0.7048832271762208,0.3446327683615819,0.7261904761904762,0.4674329501915709,0.8093392395717978,0.5006448114650062,0.33705579573522043,0.18923399440055652
|
||||
muenchen,xgboost,0.7537154989384289,0.3987341772151899,0.75,0.5206611570247934,0.815983757844223,0.5242557891617051,0.40904820462844466,0.17195990681648254
|
||||
muenchen,lightgbm,0.7515923566878981,0.3877551020408163,0.6785714285714286,0.4935064935064935,0.8122615971453181,0.5315550160005521,0.36847815988949306,0.16975197463720118
|
||||
oxford,random_forest,0.810580204778157,0.5217391304347826,0.6638297872340425,0.5842696629213483,0.842834760099003,0.6280461770360506,0.46953140892760215,0.14220733689789294
|
||||
oxford,xgboost,0.8071672354948806,0.5143769968051118,0.6851063829787234,0.5875912408759124,0.8486750380344694,0.6214727528224875,0.47319748971740944,0.13802118599414825
|
||||
oxford,lightgbm,0.8097269624573379,0.5204081632653061,0.6510638297872341,0.5784499054820416,0.8384114080701197,0.6202413328309154,0.46233779542365877,0.13681269230308113
|
||||
stanford,random_forest,0.7999124343257443,0.6654676258992805,0.757162346521146,0.7083599234205488,0.8740450864336963,0.7770736844626708,0.559726885687933,0.1423877302619292
|
||||
stanford,xgboost,0.8161120840630472,0.6968553459119496,0.7557980900409277,0.725130890052356,0.8832241312430565,0.7934283229232462,0.5884073929950523,0.1302448958158493
|
||||
stanford,lightgbm,0.8174255691768827,0.7101063829787234,0.7285129604365621,0.7191919191919192,0.8779553392917301,0.7934392862498869,0.5840718041855218,0.12889088179596303
|
||||
telaviv,random_forest,0.8055045871559633,0.5268817204301075,0.8448275862068966,0.6490066225165563,0.8872076199662406,0.7267052998356232,0.5522425615484207,0.1500184971892688
|
||||
telaviv,xgboost,0.818348623853211,0.5485714285714286,0.8275862068965517,0.6597938144329897,0.8876095169198617,0.7248530755500643,0.5640840249079071,0.13506236672401428
|
||||
telaviv,lightgbm,0.8330275229357799,0.5786163522012578,0.7931034482758621,0.6690909090909091,0.8872679045092838,0.71419228864805,0.5735279705588365,0.1302984120003824
|
||||
toronto,random_forest,0.8146067415730337,0.6116504854368932,0.7078651685393258,0.65625,0.8560998190464166,0.6936734754252618,0.5329012857891868,0.13855628609953433
|
||||
toronto,xgboost,0.827247191011236,0.6424870466321243,0.6966292134831461,0.6684636118598383,0.8769936455834701,0.7440046539927276,0.5527384390144401,0.12293894588947296
|
||||
toronto,lightgbm,0.8300561797752809,0.6557377049180327,0.6741573033707865,0.6648199445983379,0.8650422926398182,0.7332005081345564,0.5511152657981175,0.12259775056412968
|
||||
ude,random_forest,0.7611940298507462,0.2222222222222222,0.6666666666666666,0.3333333333333333,0.8497267759562841,0.46781609195402296,0.28160810322078966,0.15533642564799244
|
||||
ude,xgboost,0.7313432835820896,0.2,0.6666666666666666,0.3076923076923077,0.896174863387978,0.6018037518037518,0.25232323607491686,0.13626053929328918
|
||||
ude,lightgbm,0.835820895522388,0.3333333333333333,0.8333333333333334,0.47619047619047616,0.9262295081967212,0.6456682206682207,0.4585410702748071,0.1221060265372392
|
||||
|
@@ -1,26 +0,0 @@
|
||||
| | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:------------------------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|---------:|
|
||||
| ('berkeley', 'random_forest') | 0.765991 | 0.568502 | 0.813187 | 0.669179 | 0.854762 | 0.733088 | 0.515852 | 0.162813 |
|
||||
| ('berkeley', 'xgboost') | 0.791578 | 0.608696 | 0.794872 | 0.689436 | 0.857607 | 0.741587 | 0.54754 | 0.151892 |
|
||||
| ('berkeley', 'lightgbm') | 0.78145 | 0.60303 | 0.728938 | 0.660033 | 0.849941 | 0.735066 | 0.506 | 0.149555 |
|
||||
| ('harvard', 'random_forest') | 0.801587 | 0.575397 | 0.643016 | 0.60733 | 0.843877 | 0.657385 | 0.476446 | 0.138558 |
|
||||
| ('harvard', 'xgboost') | 0.831746 | 0.639413 | 0.676275 | 0.657328 | 0.863306 | 0.700084 | 0.546319 | 0.1246 |
|
||||
| ('harvard', 'lightgbm') | 0.82328 | 0.629712 | 0.629712 | 0.629712 | 0.855805 | 0.697239 | 0.513659 | 0.125477 |
|
||||
| ('muenchen', 'random_forest') | 0.704883 | 0.344633 | 0.72619 | 0.467433 | 0.809339 | 0.500645 | 0.337056 | 0.189234 |
|
||||
| ('muenchen', 'xgboost') | 0.753715 | 0.398734 | 0.75 | 0.520661 | 0.815984 | 0.524256 | 0.409048 | 0.17196 |
|
||||
| ('muenchen', 'lightgbm') | 0.751592 | 0.387755 | 0.678571 | 0.493506 | 0.812262 | 0.531555 | 0.368478 | 0.169752 |
|
||||
| ('oxford', 'random_forest') | 0.81058 | 0.521739 | 0.66383 | 0.58427 | 0.842835 | 0.628046 | 0.469531 | 0.142207 |
|
||||
| ('oxford', 'xgboost') | 0.807167 | 0.514377 | 0.685106 | 0.587591 | 0.848675 | 0.621473 | 0.473197 | 0.138021 |
|
||||
| ('oxford', 'lightgbm') | 0.809727 | 0.520408 | 0.651064 | 0.57845 | 0.838411 | 0.620241 | 0.462338 | 0.136813 |
|
||||
| ('stanford', 'random_forest') | 0.799912 | 0.665468 | 0.757162 | 0.70836 | 0.874045 | 0.777074 | 0.559727 | 0.142388 |
|
||||
| ('stanford', 'xgboost') | 0.816112 | 0.696855 | 0.755798 | 0.725131 | 0.883224 | 0.793428 | 0.588407 | 0.130245 |
|
||||
| ('stanford', 'lightgbm') | 0.817426 | 0.710106 | 0.728513 | 0.719192 | 0.877955 | 0.793439 | 0.584072 | 0.128891 |
|
||||
| ('telaviv', 'random_forest') | 0.805505 | 0.526882 | 0.844828 | 0.649007 | 0.887208 | 0.726705 | 0.552243 | 0.150018 |
|
||||
| ('telaviv', 'xgboost') | 0.818349 | 0.548571 | 0.827586 | 0.659794 | 0.88761 | 0.724853 | 0.564084 | 0.135062 |
|
||||
| ('telaviv', 'lightgbm') | 0.833028 | 0.578616 | 0.793103 | 0.669091 | 0.887268 | 0.714192 | 0.573528 | 0.130298 |
|
||||
| ('toronto', 'random_forest') | 0.814607 | 0.61165 | 0.707865 | 0.65625 | 0.8561 | 0.693673 | 0.532901 | 0.138556 |
|
||||
| ('toronto', 'xgboost') | 0.827247 | 0.642487 | 0.696629 | 0.668464 | 0.876994 | 0.744005 | 0.552738 | 0.122939 |
|
||||
| ('toronto', 'lightgbm') | 0.830056 | 0.655738 | 0.674157 | 0.66482 | 0.865042 | 0.733201 | 0.551115 | 0.122598 |
|
||||
| ('ude', 'random_forest') | 0.761194 | 0.222222 | 0.666667 | 0.333333 | 0.849727 | 0.467816 | 0.281608 | 0.155336 |
|
||||
| ('ude', 'xgboost') | 0.731343 | 0.2 | 0.666667 | 0.307692 | 0.896175 | 0.601804 | 0.252323 | 0.136261 |
|
||||
| ('ude', 'lightgbm') | 0.835821 | 0.333333 | 0.833333 | 0.47619 | 0.92623 | 0.645668 | 0.458541 | 0.122106 |
|
||||
@@ -1,12 +0,0 @@
|
||||
model,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
xgboost,0.8109756097560976,0.6187845303867403,0.7148936170212766,0.6633761105626851,0.8744266164789946,0.7255112168344391,0.535600710851566,0.13085858523845673
|
||||
catboost,0.815410199556541,0.6280373831775701,0.7148936170212766,0.6686567164179105,0.871187278701075,0.7229265033400272,0.5436498796133824,0.13308676740102443
|
||||
stacking_ensemble,0.8037694013303769,0.5966666666666667,0.7617021276595745,0.6691588785046729,0.8746578838240453,0.7221343045005837,0.5406113773836111,0.142284840741808
|
||||
lightgbm,0.8131929046563193,0.631163708086785,0.6808510638297872,0.6550665301944729,0.8649303008070434,0.7109401478953907,0.5279418324593667,0.13163652604161835
|
||||
random_forest,0.8004434589800443,0.5964912280701754,0.723404255319149,0.6538461538461539,0.8562202941082651,0.6943350744935747,0.5202066710761617,0.14630692947159313
|
||||
logistic_regression,0.791019955654102,0.5800344234079173,0.7170212765957447,0.6412940057088488,0.8414096143417653,0.6700032178346078,0.5017166095581281,0.15290085408182966
|
||||
svm_rbf,0.8143015521064302,0.6890756302521008,0.5234042553191489,0.5949214026602176,0.8371830042425596,0.6614524901098019,0.4849583299023803,0.13297057050989966
|
||||
decision_tree,0.7677383592017738,0.5432937181663837,0.6808510638297872,0.6043437204910292,0.8050360458068837,0.6053416508022843,0.44853834701792206,0.1718711633992893
|
||||
knn,0.7854767184035477,0.6627450980392157,0.3595744680851064,0.46620689655172415,0.7970429678777633,0.5621734577170925,0.3718006264996696,0.1496230598669623
|
||||
gaussian_nb,0.75,0.5664335664335665,0.1723404255319149,0.2642740619902121,0.778106957159718,0.5088246146088554,0.20449108478440964,0.24867163360596548
|
||||
dummy_most_frequent,0.7394678492239468,0.0,0.0,0.0,0.5,0.26053215077605324,0.0,0.26053215077605324
|
||||
|
@@ -1,13 +0,0 @@
|
||||
| model | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:--------------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|---------:|
|
||||
| xgboost | 0.810976 | 0.618785 | 0.714894 | 0.663376 | 0.874427 | 0.725511 | 0.535601 | 0.130859 |
|
||||
| catboost | 0.81541 | 0.628037 | 0.714894 | 0.668657 | 0.871187 | 0.722927 | 0.54365 | 0.133087 |
|
||||
| stacking_ensemble | 0.803769 | 0.596667 | 0.761702 | 0.669159 | 0.874658 | 0.722134 | 0.540611 | 0.142285 |
|
||||
| lightgbm | 0.813193 | 0.631164 | 0.680851 | 0.655067 | 0.86493 | 0.71094 | 0.527942 | 0.131637 |
|
||||
| random_forest | 0.800443 | 0.596491 | 0.723404 | 0.653846 | 0.85622 | 0.694335 | 0.520207 | 0.146307 |
|
||||
| logistic_regression | 0.79102 | 0.580034 | 0.717021 | 0.641294 | 0.84141 | 0.670003 | 0.501717 | 0.152901 |
|
||||
| svm_rbf | 0.814302 | 0.689076 | 0.523404 | 0.594921 | 0.837183 | 0.661452 | 0.484958 | 0.132971 |
|
||||
| decision_tree | 0.767738 | 0.543294 | 0.680851 | 0.604344 | 0.805036 | 0.605342 | 0.448538 | 0.171871 |
|
||||
| knn | 0.785477 | 0.662745 | 0.359574 | 0.466207 | 0.797043 | 0.562173 | 0.371801 | 0.149623 |
|
||||
| gaussian_nb | 0.75 | 0.566434 | 0.17234 | 0.264274 | 0.778107 | 0.508825 | 0.204491 | 0.248672 |
|
||||
| dummy_most_frequent | 0.739468 | 0 | 0 | 0 | 0.5 | 0.260532 | 0 | 0.260532 |
|
||||
@@ -1,93 +0,0 @@
|
||||
feature,importance_mean,importance_std
|
||||
patent_research_area_n.,0.10444260921031703,0.01000291629874731
|
||||
pub_rate,0.08201736179505467,0.010285677786261209
|
||||
first_publication_year,0.0547564807378144,0.006026166591504968
|
||||
industry_collab_at_index,0.0454906367927285,0.004749368941899651
|
||||
career_age_at_index,0.030337435596206636,0.0061091803388714306
|
||||
patents_at_index,0.027915583825288897,0.003703699002366671
|
||||
patent_rate,0.02257319938334216,0.0028412477089575
|
||||
patent_research_area_46,0.020719020561163842,0.004705278553964332
|
||||
publication_research_area_32,0.015048499383005075,0.002711540575849488
|
||||
years_since_first_grant,0.009081401276953966,0.002810918250730077
|
||||
grant_research_area_51,0.008390616865516776,0.001806267261854904
|
||||
institution_berkeley,0.007077813918881587,0.0020744773908402407
|
||||
pubs_at_index,0.006698549835378387,0.0027466650677884677
|
||||
grants_at_index,0.00599503440126114,0.001980142298622219
|
||||
linked_pat_pub_at_index,0.005507226827832795,0.0031018962561504865
|
||||
years_since_first_patent,0.004659123586806957,0.0022112365909527864
|
||||
grant_rate,0.004485274174139342,0.002214912214326525
|
||||
publication_research_area_31,0.0044331001338714145,0.0030081377740826198
|
||||
activities_at_index,0.004305284216529736,0.0014782296452033978
|
||||
grant_research_area_46,0.004091858156144962,0.0011631444373894524
|
||||
institution_muenchen,0.003659848471299282,0.002803323314333376
|
||||
grant_research_area_32,0.0035364026460315556,0.001234692789094628
|
||||
institution_harvard,0.0030399598700210583,0.0010328665345558197
|
||||
institution_oxford,0.002425090347126174,0.0012716207135969424
|
||||
grant_research_area_n.,0.00225639772892266,0.0010747339941249506
|
||||
publication_research_area_35,0.0020549314854987734,0.0009371249153349768
|
||||
institution_ude,0.001162683833843925,0.0006841053498902781
|
||||
institution_toronto,0.001156583492787261,0.0007606506950016298
|
||||
publication_research_area_46,0.0011120620784481894,0.0005477141022425093
|
||||
publication_research_area_51,0.0011031559479410646,0.0007678826095928305
|
||||
publication_research_area_n.,0.0010664235558135837,0.0014260233229656733
|
||||
grant_research_area_31,0.0010364325218291948,0.0004560203605407486
|
||||
grant_research_area_33,0.001024820172770624,0.0008293070226958775
|
||||
institution_stanford,0.0009809714058171327,0.0024170143165917917
|
||||
has_grants_at_index,0.0009652551908011509,0.0005840689937446477
|
||||
patent_research_area_32,0.0008854501671646586,0.0008795227637767272
|
||||
patent_research_area_37,0.0007922846156994346,0.0003202768842191713
|
||||
patent_research_area_34,0.0007533382280581757,0.0006179414386520229
|
||||
grant_research_area_40,0.0006506331487920125,0.00024905292234651626
|
||||
publication_research_area_40,0.0006333794139779525,0.0005119740114490612
|
||||
grant_research_area_44,0.0006075402293343856,0.0009861276315923473
|
||||
publication_research_area_44,0.0005199043034394668,0.00027784478444705133
|
||||
grant_research_area_52,0.0005165759383172375,0.0006805695935962879
|
||||
patent_research_area_35,0.0005135954428669542,0.0004909736821470622
|
||||
grant_research_area_35,0.0005100934296669246,0.00042419921649439104
|
||||
has_patents_at_index,0.0004675935068726766,0.0002043361710744472
|
||||
publication_research_area_36,0.000464118746512987,0.00019912666321521497
|
||||
publication_research_area_41,0.0004548894864885633,0.00047544771839497186
|
||||
publication_research_area_38,0.00041117653710123216,0.00038916428122990254
|
||||
patent_research_area_30,0.00040721947959039274,0.0002405194434829914
|
||||
grant_research_area_42,0.0003586989558202858,0.0006275379824004101
|
||||
publication_research_area_42,0.00032694798696689673,0.0004053897544270012
|
||||
patent_research_area_36,0.0003203928510275733,0.00021304776451355032
|
||||
institution_telaviv,0.00030826243735263545,0.001992324302329092
|
||||
grant_research_area_39,0.0002725435728411885,0.00022673759381254337
|
||||
publication_research_area_39,0.00026036344846201985,0.00015391601315424035
|
||||
grant_research_area_47,0.0002447153523418621,0.00028311124502635815
|
||||
publication_research_area_49,0.00023995063333196454,0.0004296785577625752
|
||||
publication_research_area_30,0.0002088399681934361,0.00020777950125951507
|
||||
patent_research_area_31,0.00019864516127749977,0.000380279221169651
|
||||
publication_research_area_37,0.00018668751279878325,0.0003857466547111577
|
||||
grant_research_area_41,0.0001861237461911358,0.00020270170413414225
|
||||
grant_research_area_34,0.000178172364924839,0.0005065287456772773
|
||||
publication_research_area_34,0.00016605431326274233,0.0012642739104362067
|
||||
patent_research_area_41,0.00016333760195231807,0.0001247795859965852
|
||||
patent_research_area_40,0.00016073261327945176,0.0006151752824866421
|
||||
publication_research_area_47,0.00010905356177434155,0.00011443403044224373
|
||||
grant_research_area_36,6.014396964046376e-05,7.141717095673809e-05
|
||||
grant_research_area_49,1.7251931083628323e-05,2.7492307340890443e-05
|
||||
grant_research_area_30,1.4864167816464047e-05,2.0438806913546228e-05
|
||||
patent_research_area_47,8.931937467215879e-06,2.6996384585526762e-05
|
||||
grant_research_area_48,0.0,0.0
|
||||
patent_research_area_52,0.0,0.0
|
||||
patent_research_area_44,0.0,0.0
|
||||
patent_research_area_48,0.0,0.0
|
||||
patent_research_area_33,0.0,0.0
|
||||
patent_research_area_39,0.0,0.0
|
||||
patent_research_area_42,0.0,0.0
|
||||
patent_research_area_43,0.0,0.0
|
||||
patent_research_area_38,0.0,0.0
|
||||
patent_research_area_49,0.0,0.0
|
||||
patent_research_area_50,0.0,0.0
|
||||
publication_research_area_43,0.0,0.0
|
||||
grant_research_area_37,-1.690891772265779e-07,6.788074255353668e-05
|
||||
grant_research_area_38,-8.25084822601574e-06,3.097726332911861e-05
|
||||
grant_research_area_50,-2.8781924222920364e-05,4.0867346872770755e-05
|
||||
grant_research_area_43,-8.555855220965803e-05,2.3804626607015977e-05
|
||||
publication_research_area_48,-8.756024432305388e-05,0.0001333723730635551
|
||||
publication_research_area_33,-0.0001731751809484261,0.0005742303072148211
|
||||
patent_research_area_51,-0.0002463145708732517,0.0001826665200607186
|
||||
publication_research_area_50,-0.000452251215090077,0.00015294072202135244
|
||||
publication_research_area_52,-0.0007332997092399818,0.0004020032943703248
|
||||
|
|
Before Width: | Height: | Size: 78 KiB |
@@ -1,11 +0,0 @@
|
||||
pubs_decile,pubs_median,p_founder_median,n
|
||||
0,4.980496919642443,0.3915597,181
|
||||
1,7.265509705598422,0.34831706,180
|
||||
2,10.829857249335916,0.41633904,180
|
||||
3,17.074329250273248,0.39508438,181
|
||||
4,25.61426887916668,0.1680935,180
|
||||
5,39.18466019195309,0.1698496,180
|
||||
6,58.63514863439843,0.14302556,181
|
||||
7,83.22335062107854,0.17652148,180
|
||||
8,136.44852188347846,0.09957586,180
|
||||
9,254.4977651893464,0.10607539,181
|
||||
|
@@ -1,5 +0,0 @@
|
||||
model,accuracy,precision,recall,f1,roc_auc,pr_auc,mcc,brier
|
||||
catboost,0.7919157415314546,0.6121112929623568,0.7442786069651741,0.6717557251908397,0.8607147674704626,0.732969623731087,0.5268819654885002,0.14595411793192087
|
||||
random_forest,0.7947623114147452,0.6219931271477663,0.7203980099502487,0.6675887505763024,0.8526728399469955,0.7221834188868932,0.5232303860768714,0.1465061594100234
|
||||
xgboost,0.7839453458582408,0.5979299363057324,0.7472636815920398,0.6643078283945157,0.854764851976164,0.7197777187580949,0.5147610429350759,0.15043815970420837
|
||||
lightgbm,0.7873612297181896,0.6123693379790941,0.699502487562189,0.6530422666047375,0.8487121807231783,0.7101883805026368,0.5030246219789863,0.1495069027701116
|
||||
|
@@ -1,6 +0,0 @@
|
||||
| model | accuracy | precision | recall | f1 | roc_auc | pr_auc | mcc | brier |
|
||||
|:--------------|-----------:|------------:|---------:|---------:|----------:|---------:|---------:|---------:|
|
||||
| catboost | 0.791916 | 0.612111 | 0.744279 | 0.671756 | 0.860715 | 0.73297 | 0.526882 | 0.145954 |
|
||||
| random_forest | 0.794762 | 0.621993 | 0.720398 | 0.667589 | 0.852673 | 0.722183 | 0.52323 | 0.146506 |
|
||||
| xgboost | 0.783945 | 0.59793 | 0.747264 | 0.664308 | 0.854765 | 0.719778 | 0.514761 | 0.150438 |
|
||||
| lightgbm | 0.787361 | 0.612369 | 0.699502 | 0.653042 | 0.848712 | 0.710188 | 0.503025 | 0.149507 |
|
||||