pgx
PGX — Lightweight Postgres for AI agents. Written in Rust. Thousands of isolated databases in one runtime. 🐘
Translation pending
A polling-average tracker for presidential approval, the generic ballot, and Senate races. More to come, but to learn more read here: https://policyypeaches.substack.com/
DataPython · CSSGitHub @HijodeaguaOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Housing my own kinda version of 538
Translation pending
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
A Python-based election modeling and forecasting system that ingests polling data from multiple sources, computes weighted polling averages, and models election outcomes.Read the full README ↗A Python-based election modeling and forecasting system that ingests polling data from multiple sources, computes weighted polling averages, and models election outcomes.
web/) that reads static JSON exported from the Python pipelinegit clone https://github.com/Hijodeagua/Election-models-by-Tre.git
cd Election-models-by-Tre
# Core + dev tools
pip install -e ".[dev]"
# Add PyMC for the state-space model (optional, ~500MB)
pip install -e ".[bayesian]"
Python 3.11+ required.
cp .env.example .env
# No API keys required for offline/CSV mode
# Add VOTEHUB_BASE_URL etc. only if you want live data fetching
# Standard weighted-average output (fast, uses bundled CSV data — no internet needed)
python scripts/run_models.py --offline
# Add Jackman state-space estimates with house-effect breakdown (~2 min, requires PyMC)
python scripts/run_models.py --offline --state-space
# Force the small hand-curated CSV fallback (5 polls per model — useful for smoke testing)
python scripts/run_models.py --source csv
pytest # 147 tests, ~8 seconds
pytest tests/test_models.py -v # just the polling engine tests
All fallback data lives in data/fallback/ and is committed to the repo — no downloads needed:
| File | Contents | Polls |
|---|---|---|
votehub_approval.csv | VoteHub approval polls, Jan 2025 – May 2026 | 683 |
votehub_generic_ballot.csv | VoteHub generic ballot polls | 344 |
silverb_approval.csv | Silver Bulletin snapshot (CLI benchmark only — not on the site) | daily |
silverb_generic_ballot.csv | Silver Bulletin snapshot (CLI benchmark only) | daily |
approval.csv / generic_ballot.csv / senate.csv | Hand-curated samples | 5 each |
Election Oracle — 2026-05-24
Presidential Approval N=683: Approve 40.3% [38.8–41.4] Net -15.9
Generic Ballot N=344: D 46.4% / R 41.1% D+5.3 → D 247 / R 188 seats
Senate (5 races): AZ Gallego +4.4 · GA Collins +1.0 · MI Peters +3.0 ...
State-space Approve: 39.5% [37.8, 40.9] σ_α=0.23pp/day
House effects (40 pollsters with |δ|>1.5pp):
InsiderAdvantage +6.6pp pro-Approve
AP-NORC -4.1pp pro-Disapprove
Quinnipiac -4.0pp pro-Disapprove
...
web/)A deployable Next.js 14 (App Router) static site that presents the trackers —
presidential approval (with a toggleable multi-model comparison chart), generic
ballot, Senate race cards (vibes toggle + market-odds chips), a Senate-control
simulation page, and a methodology page. It reads the static JSON files in
web/public/data/, which are produced by the Python pipeline; it runs no
Python server itself.
# 1. Regenerate the static JSON from the offline pipeline
python scripts/export_json.py
# 2. Build / run the front end
cd web
npm install
npm run dev # http://localhost:3000/election
npm run build # production build (static, prerendered)
The approval, generic-ballot, and race-level Senate pages are trackers: they
show weighted polling averages and confidence bands rather than election-day
predictions. The separate Senate Forecast page is a nowcast of where chamber
control stands today. It runs 50,000 simulations using race polling,
fundamentals, correlated polling error, fat-tailed uncertainty, and a transparent
prediction-market blend. It is not an election-day forecast and does not model
future campaign movement. The site is served under the /election base path
(see web/next.config.mjs).
.github/workflows/refresh_data.yml runs daily: it best-effort refreshes the
source CSVs, runs scripts/export_json.py, and commits the updated JSON. The
data refresh is offline-resilient — if a source is unreachable, the export falls
back to the committed CSVs in data/fallback/.
election-oracle/
├── config/ # Settings and pollster ratings
│ ├── settings.py # Pydantic-based configuration
│ └── pollster_ratings.json
├── src/
│ ├── data/ # Data source clients
│ │ ├── base.py # Abstract DataSource interface + Poll schema
│ │ ├── votehub.py # VoteHub API client (free, CC BY 4.0)
│ │ ├── rcp.py # RealClearPolitics scraper
│ │ ├── fiftyplusone.py # FiftyPlusOne API (paid, stub)
│ │ ├── silver_bulletin.py
│ │ └── congress_gov.py
│ ├── models/ # Election models
│ │ ├── polling_average.py # Core weighted average engine
│ │ ├── approval.py # Presidential approval model
│ │ ├── generic_ballot.py # Generic ballot + seat projection
│ │ ├── senate.py # Senate race models
│ │ ├── house.py # House race models
│ │ ├── governor.py # Governor race models
│ │ └── presidential.py # 2028 primary tracker
│ ├── analysis/ # Analytical utilities
│ │ ├── pollster_weights.py # Pollster rating management
│ │ ├── trend.py # Trend smoothing
│ │ ├── historical.py # Historical cycle comparisons
│ │ └── fundamentals.py # Non-polling fundamentals
│ ├── db/ # Database layer (SQLModel ORM)
│ │ └── models.py
│ └── dashboard/ # Streamlit dashboard
│ └── app.py
├── tests/ # Test suite
├── scripts/ # Data refresh and backfill scripts
├── notebooks/ # Jupyter exploration notebooks
└── data/ # Raw, processed, and historical data
The core engine (src/models/polling_average.py) computes weighted averages using:
| Source | Type | Cost | Status |
|---|---|---|---|
| VoteHub | API | Free (CC BY 4.0) | Implemented |
| RealClearPolitics | Scraper | Free | Implemented |
| FiftyPlusOne | API | $8/mo+ | Stub (adapter ready) |
| Silver Bulletin | CSV snapshot | Free | CLI benchmark only (removed from the site comparison — feed frozen) |
| Congress.gov | API | Free | Stub |
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src/
# Linting
ruff check .
All settings are managed via environment variables or .env file. See .env.example for available options.
Key polling average parameters are configurable in config/settings.py:
recency_half_life_days — how fast old polls decay (default: 14)lv_weight_multiplier — extra weight for likely voter polls (default: 1.5)partisan_bias_penalty — weight penalty for partisan polls (default: 0.5)MIT