Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Flat Earth AI

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.

Cover slide The model is confidently wrong on far data

How it works

  1. Ground truth. A sphere hides the base of a distant object. Visible height follows visible = max(0, H - d² / (2R)) with H = 5 m and R = 6371 km.
  2. 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.
  3. The model. One LinearRegression fits a slope (~0) and intercept (~5 m). It learns "the pole is always 5 m."
  4. Case 2 (the honest data). Readings out to 10 km, where the pole visibly loses its base.
  5. 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.

Quick start

Backend (port 8000)

cd backend
python -m venv .venv && source .venv/bin/activate   # optional
pip install -r requirements.txt
uvicorn main:app --reload

Frontend (port 5173)

cd frontend
npm install
npm run dev

Open 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.

Export the LinkedIn carousel

With both servers running, render every slide to a 1080×1080 page and stitch them into a PDF:

cd frontend
npm run export:pdf

Output 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).

Project structure

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

Tech stack

  • Backend: Python, FastAPI, scikit-learn, NumPy
  • Frontend: React, TypeScript, Vite, Recharts
  • Export: Playwright, pdf-lib

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages