A zero-dependency logistic regression that picks the optimal daily goal by maximizing expected value (probability of success × goal value).
The core idea: a lower goal is easier but worth less. A higher goal is worth more but you're less likely to hit it. The EV peak is the sweet spot. The model trains fresh on your history every time you ask — no stale weights.
Import the optimizer directly:
import { recommend, explain } from "https://esm.town/v/dcm31/ev-goal-optimizer/optimizer.ts";
const history = [
{ date: "2026-03-01", goal: 20, actual: 22, achieved: 1 },
{ date: "2026-03-02", goal: 22, actual: 18, achieved: 0 },
// ... 10+ days needed
];
const result = recommend(history, "2026-03-08");
// { best: { goal: 24, prob: 0.58, ev: 13.9 }, sweep: [...] }
const why = explain(history, 24, "2026-03-08");
// { prob: 0.58, ev: 13.9, contributions: [{ feature: "streak", value: 3, weight: 0.42 }, ...] }
Or hit the HTTP API:
POST /api/recommend
{ "history": [...], "targetDate": "2026-03-08", "goalMin": 1, "goalMax": 50 }
GET /api/recommend runs on randomly generated demo data.
The explain function shows which features are pushing the probability up or down, sorted by magnitude.
Works with Val Town SQLite for persistence, Apple Shortcuts for logging, Beeminder for commitment, Fatebook for calibration tracking. See the blog post for the full system.