Download expansion_v2/source/src/write_cards.py from Giuliocc/windtunnel-response-data: direct link, hf CLI and curl.
- Browser
- Download file 14.5 kB
-
https://huggingface.co/datasets/Giuliocc/windtunnel-response-data/resolve/main/expansion_v2/source/src/write_cards.py
- Command line
-
hf download hf://datasets/Giuliocc/windtunnel-response-data/expansion_v2/source/src/write_cards.py
-
curl -L -o write_cards.py https://huggingface.co/datasets/Giuliocc/windtunnel-response-data/resolve/main/expansion_v2/source/src/write_cards.py
14.5 kB
| from pathlib import Path | |
| import json,shutil | |
| ROOT=Path(__file__).resolve().parents[1] | |
| read=lambda p:json.loads(Path(p).read_text()) | |
| k=read(ROOT/'results/known-evaluation.json');s=read(ROOT/'results/known-slices.json');c=read(ROOT/'results/cross-wave-evaluation.json');e=read(ROOT/'results/encoder/evaluation.json') | |
| def metric(row):return f"{row['half_multiclass_brier']:.6f} | {row['total_variation']:.6f}" | |
| def write(p,s):Path(p).write_text(s) | |
| base='''## Exact-instrument replay | |
| Use `runtime.py::predict(model_dir, request)` with the trusted manifest SHA-256, | |
| question ID, full instrument hash, coarse cell ID and explicit mode. The runtime | |
| verifies every loaded artifact and option-ID mapping. Changed wording, preceding | |
| context, language, options, unsupported cells and future-wave modes abstain. | |
| See `INSTALL.md` and `example-request.json`. Baseline and cross-wave replay use | |
| only the Python standard library. Probabilities are recorded-answer distributions, | |
| including offered uncertainty, conditional on answering; missing, skipped and | |
| not-asked records are excluded. These outputs do not predict a named person's | |
| beliefs or support persuasion/personalized political messaging. | |
| ## Limits | |
| CES is a matched opt-in panel using `commonweight`, not a probability sample. | |
| Age-by-education cells are coarse (four age bins by three education bins) and | |
| cannot resolve political identity, location, detailed demographics or causal | |
| mechanisms. Published reference intervals condition on the fixed instruments | |
| and models. They exclude coverage/nonresponse bias, training variation and | |
| new-question/family uncertainty. The same respondent multiplier is used across | |
| all items in paired bootstraps; this retains repeated-question dependence but | |
| does not turn batteries into independent sampled domains. | |
| The recorded outcomes were historical and public. This release is not a | |
| prospective or independently human-adjudicated study. `source-receipts.json` | |
| records exact official source files, CC0 rights and dates; model/source hashes | |
| identify bytes rather than prove independent methodological validation. | |
| [Original response data](https://huggingface.co/datasets/Giuliocc/windtunnel-response-data) | |
| · [Original cross-wave data](https://huggingface.co/datasets/Giuliocc/windtunnel-ces-cross-wave) | |
| · [Wind Tunnel](https://windtunnel.tacitus.me/research/response-lab) | |
| ''' | |
| known=f'''--- | |
| license: apache-2.0 | |
| language: en | |
| datasets: | |
| - Giuliocc/windtunnel-response-data | |
| tags: | |
| - survey-research | |
| - weighted-response-distributions | |
| - exact-instrument | |
| --- | |
| # Wind Tunnel exact-instrument shrinkage model | |
| A real, one-thread CPU-trained model for **52 CES 2024 V9 pre-election | |
| instruments**, preserving all original 16 instrument hashes and adding 36 | |
| questions. The registry covers twelve questionnaire batteries, four more than | |
| the original eight. It estimates recorded | |
| answers in supported coarse age-by-education cells. It passed the registered | |
| same-wave comparison, independently recomputed by a separate automated audit | |
| from the raw source CSV, exact checkpoint probabilities and all 400 bootstrap | |
| replicates. That audit is distinct from human peer review. | |
| The model shrinks weighted empirical cell distributions toward a fitted additive | |
| multinomial logistic predictor. Cell Kish effective sample size determines the | |
| strength of the cell estimate. One global alpha (`{k['selected_alpha']}`) was | |
| selected on development respondents, then frozen before test evaluation. | |
| Training/development/test respondent counts are 41,500/8,880/8,791, using the | |
| verified original SHA-256 assignment. No individual records are included. | |
| | Fixed 52 instruments | Within-cell expected half Brier | Within-cell TV | | |
| | --- | ---: | ---: | | |
| | Additive logistic comparator | {metric(k['additive']['within_cell'])} | | |
| | Selected shrinkage model | {metric(k['candidate']['within_cell'])} | | |
| The absolute half-Brier improvement is {k['improvement']:.6f}. The paired | |
| fixed-model 95% interval for candidate minus comparator is | |
| [{k['paired_bootstrap']['interval'][0]:.6f}, {k['paired_bootstrap']['interval'][1]:.6f}]. | |
| This is a modest improvement in a narrowly defined task, not evidence of general | |
| political forecasting. | |
| The **36 added instruments** improve half Brier by | |
| {s['slices']['additional_36']['comparator']['within_cell']['half_multiclass_brier']-s['slices']['additional_36']['candidate']['within_cell']['half_multiclass_brier']:.6f} | |
| against their additive comparator. On the **original 16 instruments**, replay of | |
| the actual previously published baseline improves by | |
| {s['slices']['legacy_16']['comparator']['within_cell']['half_multiclass_brier']-s['slices']['legacy_16']['candidate']['within_cell']['half_multiclass_brier']:.6f}. | |
| See `slice-evaluation.json` for both denominators, paired intervals and all | |
| battery-level results. The original baseline files remain unchanged. | |
| All source counts reconcile against the official guide. Full coarse-cell | |
| reference breakouts are withheld when any option/cell has fewer than ten answers | |
| or residual unknown cells permit subtraction. Minimum training support is 100 | |
| answers and Kish effective n of 50. Source field dates: **2024-10-01 to | |
| 2024-11-04**. Use mode `known-item`. | |
| '''+base | |
| write(ROOT/'stage/known-item-v2/README.md',known) | |
| cross=f'''--- | |
| license: apache-2.0 | |
| language: en | |
| datasets: | |
| - Giuliocc/windtunnel-ces-cross-wave | |
| tags: | |
| - survey-research | |
| - temporal-transfer | |
| - exact-instrument | |
| --- | |
| # Wind Tunnel additional historical cross-wave instruments | |
| Eight additional exact text-and-option pairs transfer CES **2022 V4** fits to | |
| CES **2024 V9** test respondents. Three questionnaire families are represented; | |
| six of eight pairs share one ideology-placement battery. Ideology placement is | |
| the only family added relative to the original twelve-pair benchmark. The source | |
| questionnaire pages, instrument hashes, option IDs and transcription limitations | |
| are inspectable in `instrument-crosswalk.json`. | |
| Historical parameters use only eligible 2022 answers. The distinct | |
| `2024-development-calibrated` mode adds log-odds offsets fit only on 2024 | |
| development labels. That label-assisted mode is not a no-label forecast or proof | |
| of calibrated reliability. Both modes were fixed before their test scoring. | |
| The target outcomes were historical/public and also appeared in a separate | |
| encoder diagnostic; this is additional retrospective evidence. | |
| | Additional eight fixed instruments | Within-cell expected half Brier | Within-cell TV | | |
| | --- | ---: | ---: | | |
| | 2022 marginal | {metric(c['means']['historical_marginal']['within_cell'])} | | |
| | 2022-only historical logistic | {metric(c['means']['historical']['within_cell'])} | | |
| | 2024 development marginal | {metric(c['means']['target_dev_marginal']['within_cell'])} | | |
| | 2024 development-offset logistic | {metric(c['means']['label_assisted']['within_cell'])} | | |
| The historical half-Brier gain over the 2022 marginal is | |
| {c['historical_gain']:.6f}; the paired fixed-model 95% interval for the difference | |
| is [{c['paired_bootstrap']['interval'][0]:.6f}, {c['paired_bootstrap']['interval'][1]:.6f}]. | |
| The first-pass numerical comparison passes under represented-family coverage, | |
| but the registered novelty wording is ambiguous: only one family is entirely new | |
| relative to v1. Conservative release qualification therefore blocks publication | |
| of these replacement weights. This directory is a local comparison only. | |
| The empirical evidence is restricted to these exact | |
| historical instruments and supported cells, not a later-wave or unseen-question | |
| release. National scores condition on observed target test answerer composition. | |
| Field dates remain distinct: **2022-09-29 to 2022-11-08** and **2024-10-01 to | |
| 2024-11-04**. Different surrounding surveys and political periods may change | |
| responses even with the same item. Release-local case-ID comparisons cannot | |
| establish disjoint real people; repeat panelists remain possible. No real-person | |
| independence claim is made. The original model and twelve-pair evidence remain | |
| available separately and are not overwritten. | |
| '''+base | |
| write(ROOT/'stage/cross-wave-v2/README.md',cross) | |
| encoder=f'''--- | |
| license: apache-2.0 | |
| language: en | |
| base_model: sentence-transformers/all-MiniLM-L6-v2 | |
| base_model_relation: finetune | |
| --- | |
| # Wind Tunnel encoder: expanded diagnostic, original checkpoint retained | |
| This bundle retains the actual original adapter from | |
| `Giuliocc/windtunnel-response-encoder` at its pinned source revision. A new | |
| one-thread CPU experiment expanded the option-encoder study to 46 instruments: | |
| 23 training questions/five families, five development questions/two families, | |
| and 18 test questions/four families. The two additional test families are | |
| ideological placement and voting intention. The mixed congressional-bill battery | |
| was excluded because it overlaps training/development topics. | |
| | Expanded fixed test suite | Expected half Brier | TV | | |
| | --- | ---: | ---: | | |
| | Uniform | {e['encoder_finetuned']['means']['uniform_half_multiclass_brier']:.6f} | {e['encoder_finetuned']['means']['uniform_total_variation']:.6f} | | |
| | Original released adapter | {metric(e['released_v1_adapter']['means'])} | | |
| | New frozen encoder probe | {metric(e['frozen_encoder_probe']['means'])} | | |
| | New final-block adapter | {metric(e['encoder_finetuned']['means'])} | | |
| **The replacement failed.** Its proper score is worse than the probe, original | |
| adapter and uniform baseline. Four independent test families also remain below | |
| the registered ten-family minimum. The original two-family public-test weakness | |
| has not disappeared. The newly trained replacement weights are excluded from | |
| publication. `expansion-evaluation.json`, `expansion-training.json` and | |
| `expansion-roles.json` preserve the failure and checkpoint-selection evidence. | |
| The checked local runner actually reloads the original pinned MiniLM base and | |
| adapter, verifies all digests, and reproduces reference probabilities. This is a | |
| research inference path, not a promoted new-question response service. Use mode | |
| `encoder-research`; it requires explicit exact registry identity and supported | |
| coarse cells. See `INSTALL.md` for local base download and dependencies. | |
| '''+base | |
| write(ROOT/'stage/encoder-v1/README.md',encoder) | |
| for bundle in ['baseline-v1','cross-wave-v1']: | |
| source='windtunnel-response-baseline' if bundle=='baseline-v1' else 'windtunnel-response-cross-wave' | |
| original=(ROOT/'inputs'/source/'README.md').read_text() | |
| write(ROOT/'stage'/bundle/'README.md',original+'\n\n## Verified local replay extension\n\nThe original model bytes are retained. `runtime.py`, `runtime-manifest.json` and\n`example-request.json` add checksummed exact-instrument replay and explicit\nabstention. See `INSTALL.md` for the local API. No new accuracy claim is made\nfor this unchanged checkpoint.\n') | |
| p=ROOT/'stage/cross-wave-v1/README.md' | |
| p.write_text(p.read_text()+'\n## Additional eight-instrument evidence\n\n`expansion-evaluation.json` and `expansion-instrument-crosswalk.json` add eight\nexact historical item pairs across three represented families. Only one family\nis entirely new relative to v1. The numerical comparison improves over the\n2022 marginal, but `expansion-release-qualification.json` blocks replacement\nweights because the predeclared new-family gate is ambiguous. The original\nmodel remains unchanged. Historical public outcomes and a separate encoder\ndiagnostic exposed target labels; no fresh or prospective validation is claimed.\n') | |
| data='''--- | |
| license: cc0-1.0 | |
| language: en | |
| configs: | |
| - config_name: exact_questions_v2 | |
| data_files: | |
| - split: all | |
| path: questions.parquet | |
| - config_name: national_reference_v2 | |
| data_files: | |
| - split: test | |
| path: national-reference.parquet | |
| - config_name: supported_cells_v2 | |
| data_files: | |
| - split: test | |
| path: supported-cell-reference.parquet | |
| --- | |
| # Wind Tunnel 52-instrument aggregate extension | |
| 52 exact CES 2024 V9 pre-election instruments, 36 additional to the original | |
| release, span twelve questionnaire batteries. These are **real recorded survey | |
| answers**, not annotations of political bias and not synthetic respondents. | |
| The original 16 full instrument hashes and original respondent split are | |
| preserved. Fields include exact stem, stimulus, preceding context, option IDs, | |
| field dates, source license/location/hash, battery and topic-overlap groups. | |
| The frozen test roster has 8,791 eligible citizen-adult respondents. The native | |
| tables contain 52 national reference rows and 444 supported coarse-cell rows; | |
| these reuse the same respondent roster and must not be counted as independent | |
| people. Full coarse breakouts are suppressed if any option/cell has fewer than | |
| ten answers or unknown-cell subtraction is possible. All 52 national rows pass | |
| the minimum category rule. No respondent IDs or individual responses are included. | |
| Age bins are 18–29, 30–44, 45–64 and 65+; education bins are high school or less, | |
| some college/associate, and bachelor's or higher. Cell support is not an | |
| entitlement to individual profiling or detailed demographic/geographic claims. | |
| `commonweight` is used. Kish effective n and descriptive weight-only normal | |
| intervals identify limited reference precision; they are not probability-sample | |
| confidence intervals or complete uncertainty for matched opt-in panels. | |
| The original guide/DOCX mismatch for ideology item code 8 is disclosed: code 8 | |
| is an offered Not sure answer and is retained, with all eight option counts | |
| reconciled to the official guide. Templated/routed questions, free text, | |
| multiple-answer matrices and continuous sliders are excluded. All field dates | |
| remain 2024-10-01 to 2024-11-04. No independent human methodological review was | |
| performed by this automated build. Exact source receipts and reconciliation | |
| are separate from substantive model validation. | |
| CES Common Content 2024 V9 is CC0-1.0: | |
| https://doi.org/10.7910/DVN/X11EP6. The build retains an aggregate-only release | |
| policy. Original response-level CSV data remain local for reproducibility. | |
| See `source-identity.json`, `source-receipts.json` and `source-reconciliation.json`. | |
| ''' | |
| write(ROOT/'stage/data-v2/README.md',data) | |
| for folder in (ROOT/'stage').iterdir(): | |
| if not folder.is_dir():continue | |
| for source,name in [(ROOT/'INSTALL.md','INSTALL.md'),(ROOT/'NOTICE','NOTICE'),(ROOT/'results/source-receipts.json','source-receipts.json')]:shutil.copy2(source,folder/name) | |
| if folder.name=='data-v2':shutil.copy2(ROOT/'results/source_reconciliation.json',folder/'source-reconciliation.json') | |
| print('Cards written from actual metrics; failed encoder weights excluded.') | |