I taught an AI the Earth is flat. It was completely confident about it.
A tiny, honest demo of one idea: a model is only as honest as its training data.
A normal scikit-learn LinearRegression is trained on 40 real-style measurements of how much of a pole stays visible over distance (the Bedford Level experiment). When it only learns from readings taken close to the pole, where Earth's curvature is invisible, it concludes the world is flat and keeps predicting a full pole even far away, where the real pole has dropped below the horizon.
The model never "breaks." It does exactly what its data taught it. The data is the problem.
- Ground truth. A sphere hides the base of a distant object. Visible height follows
visible = max(0, H - d² / (2R))withH = 5 mandR = 6371 km. - Case 1 (training data). 40 readings taken within 1 km of the pole. The whole pole is always visible (~5 m), so the data looks flat.
- The model. One
LinearRegressionfits a slope (~0) and intercept (~5 m). It learns "the pole is always 5 m." - Case 2 (the honest data). Readings out to 10 km, where the pole visibly loses its base.
- The reveal. The same, never-retrained model still predicts a flat 5 m line. On the far data the error is the full height of the pole.
The takeaway: narrow training data produces a confident, wrong model. Feed it the messy edges, not just the comfy middle.
cd backend
python -m venv .venv && source .venv/bin/activate # optional
pip install -r requirements.txt
uvicorn main:app --reloadcd frontend
npm install
npm run devOpen http://localhost:5173. Vite proxies /api to the backend. Click or use the arrow keys to move through the slides.
Data is deterministic via the seed: GET /api/demo?seed=42.
With both servers running, render every slide to a 1080×1080 page and stitch them into a PDF:
cd frontend
npm run export:pdfOutput lands in frontend/export/:
carousel.pdf: upload to LinkedIn via "Add a document"slide-01.png…slide-NN.png: individual squares (2160×2160)
Override the target with EXPORT_URL=http://localhost:4173 npm run export:pdf. The script uses your installed Google Chrome (no extra browser download).
backend/
main.py # FastAPI app, GET /api/demo
datasets.py # Case 1 (near) + Case 2 (full range) data, ground-truth curvature
model.py # sklearn LinearRegression + overlays
frontend/
src/
App.tsx
components/
SlideDeck.tsx # the slide-by-slide story
CaseIllustration.tsx # SVG diagrams (near / far)
DataPanel.tsx # Recharts scatter + regression line
MiniDataSample.tsx # raw data table
scripts/
export-pdf.mjs # Playwright + pdf-lib carousel exporter
docs/ # preview images for this README
- Backend: Python, FastAPI, scikit-learn, NumPy
- Frontend: React, TypeScript, Vite, Recharts
- Export: Playwright, pdf-lib
MIT

