EV Goal Optimizer

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.

Use it

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.

How it works

  1. Engineers ~18 features from your history: streak direction, 7/14-day rolling success rates, day-of-week (both cyclic encoding and one-hot), effort ratios, goal momentum
  2. Z-score normalizes all features
  3. Trains logistic regression via gradient descent with L2 regularization (500 iterations, lr=0.1, λ=0.02)
  4. Sweeps candidate goals from min to max, predicts P(success) for each
  5. Picks the goal with the highest P(success) × goal

The explain function shows which features are pushing the probability up or down, sorted by magnitude.

Remix ideas

  • Daily writing goal (words/pages)
  • Meditation minutes
  • Sales calls
  • Pull-ups / push-ups
  • Anything where you want adaptive difficulty

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.