supermodel-ml 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- supermodel_ml-0.1.0/PKG-INFO +330 -0
- supermodel_ml-0.1.0/README.md +301 -0
- supermodel_ml-0.1.0/pyproject.toml +57 -0
- supermodel_ml-0.1.0/setup.cfg +4 -0
- supermodel_ml-0.1.0/supermodel/__init__.py +3 -0
- supermodel_ml-0.1.0/supermodel/backtest.py +111 -0
- supermodel_ml-0.1.0/supermodel/cli.py +621 -0
- supermodel_ml-0.1.0/supermodel/config.py +274 -0
- supermodel_ml-0.1.0/supermodel/deps.py +66 -0
- supermodel_ml-0.1.0/supermodel/eda.py +283 -0
- supermodel_ml-0.1.0/supermodel/experiments.py +86 -0
- supermodel_ml-0.1.0/supermodel/guards.py +416 -0
- supermodel_ml-0.1.0/supermodel/hooks/guard_bash.py +13 -0
- supermodel_ml-0.1.0/supermodel/hooks/guard_write.py +13 -0
- supermodel_ml-0.1.0/supermodel/hooks/session_end.py +13 -0
- supermodel_ml-0.1.0/supermodel/hooks/session_start.py +13 -0
- supermodel_ml-0.1.0/supermodel/install.py +162 -0
- supermodel_ml-0.1.0/supermodel/integrity.py +184 -0
- supermodel_ml-0.1.0/supermodel/kinds/__init__.py +31 -0
- supermodel_ml-0.1.0/supermodel/kinds/base.py +99 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/__init__.py +71 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/backtest.py +52 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/config.py +22 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/kind.py +515 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/.claude/commands/eda.md +13 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/.claude/commands/new-experiment.md +13 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/CLAUDE.md +37 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/eda/CLAUDE.md +5 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/eval/CLAUDE.md +5 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/eval/evaluate.py +39 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/eval/helpers.py +17 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/experiments/CLAUDE.md +6 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/modeling/CLAUDE.md +6 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/modeling/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/modeling/base.py +17 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/modeling/methods/__init__.py +1 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/modeling/registry.py +45 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/runner/CLAUDE.md +3 -0
- supermodel_ml-0.1.0/supermodel/kinds/custom/template/runner/kind.py +191 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/__init__.py +67 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/backtest.py +114 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/config.py +269 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/kind.py +549 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/CLAUDE.md +43 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/eda/CLAUDE.md +5 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/eval/CLAUDE.md +3 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/eval/build_splits.py +911 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/eval/evaluate.py +240 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/eval/metrics.py +230 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/experiments/CLAUDE.md +6 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/CLAUDE.md +16 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/__init__.py +1 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/base.py +371 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/estimators/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/estimators/baselines.py +107 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/estimators/gbm.py +110 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/model_classes/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/model_classes/tabular.py +13 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/registry.py +123 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/steps/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/steps/features.py +32 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/steps/preprocess.py +149 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/tests/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/modeling/tests/test_contract.py +32 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/runner/CLAUDE.md +6 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/runner/data.py +125 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/runner/folds.py +82 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/runner/kind.py +121 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/runner/predict.py +149 -0
- supermodel_ml-0.1.0/supermodel/kinds/supervised/template/runner/train.py +100 -0
- supermodel_ml-0.1.0/supermodel/memory.py +279 -0
- supermodel_ml-0.1.0/supermodel/modeler.py +645 -0
- supermodel_ml-0.1.0/supermodel/paths.py +98 -0
- supermodel_ml-0.1.0/supermodel/profile.py +137 -0
- supermodel_ml-0.1.0/supermodel/project_imports.py +24 -0
- supermodel_ml-0.1.0/supermodel/reports.py +92 -0
- supermodel_ml-0.1.0/supermodel/review.py +306 -0
- supermodel_ml-0.1.0/supermodel/scaffold.py +367 -0
- supermodel_ml-0.1.0/supermodel/splits.py +248 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/backtest.md +12 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/brief.md +10 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/eda.md +13 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/new-experiment.md +13 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/setup.md +34 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/status.md +4 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/commands/wrap-up.md +7 -0
- supermodel_ml-0.1.0/supermodel/template/.claude/settings.json +17 -0
- supermodel_ml-0.1.0/supermodel/template/AGENTS.md +27 -0
- supermodel_ml-0.1.0/supermodel/template/CLAUDE.md +18 -0
- supermodel_ml-0.1.0/supermodel/template/DATA_ACCESS.md +6 -0
- supermodel_ml-0.1.0/supermodel/template/champion/CLAUDE.md +2 -0
- supermodel_ml-0.1.0/supermodel/template/data/CLAUDE.md +2 -0
- supermodel_ml-0.1.0/supermodel/template/docs/CLAUDE.md +8 -0
- supermodel_ml-0.1.0/supermodel/template/eda/CLAUDE.md +6 -0
- supermodel_ml-0.1.0/supermodel/template/eval/CLAUDE.md +2 -0
- supermodel_ml-0.1.0/supermodel/template/eval/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/template/experiments/CLAUDE.md +2 -0
- supermodel_ml-0.1.0/supermodel/template/memory/CLAUDE.md +4 -0
- supermodel_ml-0.1.0/supermodel/template/modeling/CLAUDE.md +2 -0
- supermodel_ml-0.1.0/supermodel/template/runner/CLAUDE.md +2 -0
- supermodel_ml-0.1.0/supermodel/template/runner/__init__.py +0 -0
- supermodel_ml-0.1.0/supermodel/template/runner/ledger.py +73 -0
- supermodel_ml-0.1.0/supermodel/template/runner/run.py +341 -0
- supermodel_ml-0.1.0/supermodel/template/utils/CLAUDE.md +5 -0
- supermodel_ml-0.1.0/supermodel/template/utils/__init__.py +1 -0
- supermodel_ml-0.1.0/supermodel/testing/__init__.py +2 -0
- supermodel_ml-0.1.0/supermodel/testing/contract.py +293 -0
- supermodel_ml-0.1.0/supermodel/testing/custom_project.py +91 -0
- supermodel_ml-0.1.0/supermodel/testing/data.py +133 -0
- supermodel_ml-0.1.0/supermodel/testing/fakes.py +296 -0
- supermodel_ml-0.1.0/supermodel/testing/project.py +296 -0
- supermodel_ml-0.1.0/supermodel/testing/revenue.py +143 -0
- supermodel_ml-0.1.0/supermodel/tests/conftest.py +88 -0
- supermodel_ml-0.1.0/supermodel/tests/fixtures/old_runner_data.py +105 -0
- supermodel_ml-0.1.0/supermodel/tests/snapshots/synth_classification.tsv +16 -0
- supermodel_ml-0.1.0/supermodel/tests/snapshots/synth_forecasting.tsv +15 -0
- supermodel_ml-0.1.0/supermodel/tests/snapshots/synth_ranking.tsv +15 -0
- supermodel_ml-0.1.0/supermodel/tests/snapshots/synth_regression.tsv +15 -0
- supermodel_ml-0.1.0/supermodel/tests/test_ablation_workflow.py +108 -0
- supermodel_ml-0.1.0/supermodel/tests/test_backtest.py +55 -0
- supermodel_ml-0.1.0/supermodel/tests/test_config.py +138 -0
- supermodel_ml-0.1.0/supermodel/tests/test_custom_e2e.py +56 -0
- supermodel_ml-0.1.0/supermodel/tests/test_custom_engine.py +692 -0
- supermodel_ml-0.1.0/supermodel/tests/test_custom_runner.py +142 -0
- supermodel_ml-0.1.0/supermodel/tests/test_docs.py +30 -0
- supermodel_ml-0.1.0/supermodel/tests/test_e2e.py +240 -0
- supermodel_ml-0.1.0/supermodel/tests/test_eda.py +59 -0
- supermodel_ml-0.1.0/supermodel/tests/test_enforcement.py +442 -0
- supermodel_ml-0.1.0/supermodel/tests/test_evaluate.py +183 -0
- supermodel_ml-0.1.0/supermodel/tests/test_flexible_splits.py +313 -0
- supermodel_ml-0.1.0/supermodel/tests/test_fold_integrity.py +217 -0
- supermodel_ml-0.1.0/supermodel/tests/test_freeze_flow.py +154 -0
- supermodel_ml-0.1.0/supermodel/tests/test_kind_contract.py +330 -0
- supermodel_ml-0.1.0/supermodel/tests/test_kinds_config.py +91 -0
- supermodel_ml-0.1.0/supermodel/tests/test_ledger.py +54 -0
- supermodel_ml-0.1.0/supermodel/tests/test_metrics.py +92 -0
- supermodel_ml-0.1.0/supermodel/tests/test_modeling.py +266 -0
- supermodel_ml-0.1.0/supermodel/tests/test_project_imports.py +59 -0
- supermodel_ml-0.1.0/supermodel/tests/test_review.py +137 -0
- supermodel_ml-0.1.0/supermodel/tests/test_rolling_origin.py +145 -0
- supermodel_ml-0.1.0/supermodel/tests/test_runner_seam.py +28 -0
- supermodel_ml-0.1.0/supermodel/tests/test_scaffold_and_pin.py +210 -0
- supermodel_ml-0.1.0/supermodel/tests/test_shadowing.py +108 -0
- supermodel_ml-0.1.0/supermodel/tests/test_splits.py +211 -0
- supermodel_ml-0.1.0/supermodel/tests/test_trust_standard.py +101 -0
- supermodel_ml-0.1.0/supermodel/tests/test_venv.py +87 -0
- supermodel_ml-0.1.0/supermodel/user_commands/init-project.md +15 -0
- supermodel_ml-0.1.0/supermodel/util.py +72 -0
- supermodel_ml-0.1.0/supermodel/venv.py +149 -0
- supermodel_ml-0.1.0/supermodel_ml.egg-info/PKG-INFO +330 -0
- supermodel_ml-0.1.0/supermodel_ml.egg-info/SOURCES.txt +153 -0
- supermodel_ml-0.1.0/supermodel_ml.egg-info/dependency_links.txt +1 -0
- supermodel_ml-0.1.0/supermodel_ml.egg-info/entry_points.txt +2 -0
- supermodel_ml-0.1.0/supermodel_ml.egg-info/requires.txt +15 -0
- supermodel_ml-0.1.0/supermodel_ml.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: supermodel-ml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An agent-driven ML workspace: gives any coding agent the tooling and structure to run trustworthy ML experiments.
|
|
5
|
+
Project-URL: Homepage, https://github.com/jeffmli/supermodel
|
|
6
|
+
Project-URL: Repository, https://github.com/jeffmli/supermodel
|
|
7
|
+
Project-URL: Issues, https://github.com/jeffmli/supermodel/issues
|
|
8
|
+
Keywords: machine-learning,experiments,agents,claude-code,reproducibility,evaluation
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: numpy>=1.26
|
|
15
|
+
Requires-Dist: pandas>=2.1
|
|
16
|
+
Requires-Dist: pyarrow>=14
|
|
17
|
+
Requires-Dist: scikit-learn>=1.4
|
|
18
|
+
Requires-Dist: pyyaml>=6
|
|
19
|
+
Requires-Dist: joblib>=1.3
|
|
20
|
+
Requires-Dist: lightgbm>=4.0
|
|
21
|
+
Requires-Dist: xgboost>=2.0
|
|
22
|
+
Requires-Dist: torch>=2.3
|
|
23
|
+
Requires-Dist: pyrage>=1.1
|
|
24
|
+
Requires-Dist: marimo>=0.26
|
|
25
|
+
Requires-Dist: pexpect>=4.9
|
|
26
|
+
Requires-Dist: packaging>=23
|
|
27
|
+
Requires-Dist: pytest>=8
|
|
28
|
+
Requires-Dist: pytest-timeout>=2.2
|
|
29
|
+
|
|
30
|
+
# Supermodel
|
|
31
|
+
|
|
32
|
+
**An agent-driven ML workspace. Run ML experiments with a coding agent, trust that the results are valid, and keep the project clean enough to understand months later.**
|
|
33
|
+
|
|
34
|
+
Coding agents (Claude Code, Codex, or any harness that reads `AGENTS.md`) can already write model code. What they don't do on their own is keep an ML project in order. Supermodel gives the agent a structured workspace, a CLI and a set of rules, so you get two things at once:
|
|
35
|
+
|
|
36
|
+
1. **Results you can trust.** The evaluation is frozen and hashed, preprocessing only ever sees training rows, the test set is sealed, and a runner writes every score. The agent never types one.
|
|
37
|
+
2. **A workspace that stays clean.** Every kind of file has one home, every experiment is recorded with its hypothesis, config, score and exact code, and any past result can be traced and rerun.
|
|
38
|
+
|
|
39
|
+
You describe what you want in plain language ("predict which users churn", "try LightGBM with target encoding", "what did we try last week?"). The agent puts each piece in the right folder and runs the right command.
|
|
40
|
+
|
|
41
|
+
Two kinds of project are supported:
|
|
42
|
+
|
|
43
|
+
- **supervised**: classification, regression, ranking and forecasting on tabular data.
|
|
44
|
+
- **custom**: any method (allocation, optimization, simulation) scored by an evaluator you write.
|
|
45
|
+
|
|
46
|
+
See [`docs/spec.md`](docs/spec.md) for the design.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## The problem
|
|
51
|
+
|
|
52
|
+
Point a coding agent at a dataset and ask it to "try a few models", and you get results quickly. A few days later the project looks like this:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
train.py train_v2.py train_lgbm_final.py train_lgbm_final_FIXED.py
|
|
56
|
+
features.py features_new.py eval.py quick_check.py test_split.py
|
|
57
|
+
notebook1.ipynb Untitled3.ipynb results.csv results_old.csv model.pkl
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### The workspace turns into a mess
|
|
61
|
+
|
|
62
|
+
- **File sprawl.** The agent writes a new script for every idea. Throwaway checks, half-finished variants and the code that matters sit side by side.
|
|
63
|
+
- **You lose track of what you tested.** There's no record of which experiments ran, what each one was trying to show, or how it scored.
|
|
64
|
+
- **Old code gets overwritten.** The agent is free to edit any file, including the code behind last week's best result. Once it changes, that result can't be reproduced.
|
|
65
|
+
- **You can't go back.** When someone asks how the current model was built, or why an idea was dropped, the answer is spread across chat logs and stale files.
|
|
66
|
+
|
|
67
|
+
### The results can't be trusted
|
|
68
|
+
|
|
69
|
+
- **Leakage nobody notices.** A scaler is fit on the full dataset, early stopping watches the validation fold, or a feature quietly encodes the target. The score looks great and means nothing.
|
|
70
|
+
- **A moving yardstick.** The split, metric or holdout gets changed between runs, sometimes "to fix a bug". Then E007 and E012 can't be compared.
|
|
71
|
+
- **Numbers typed, not measured.** The agent summarizes a result from memory or a truncated log, and the summary drifts from what actually ran.
|
|
72
|
+
- **Holdout erosion.** Every peek at the test set turns it into one more validation set.
|
|
73
|
+
|
|
74
|
+
You end up re-checking the agent's work line by line and cleaning up after it, which defeats the point of using one.
|
|
75
|
+
|
|
76
|
+
## How Supermodel fixes it
|
|
77
|
+
|
|
78
|
+
### A clean, organized workspace
|
|
79
|
+
|
|
80
|
+
The same project in Supermodel:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
supermodel.yaml task, split, holdout, metric: the evaluation contract
|
|
84
|
+
data/ raw data or a pointer to it
|
|
85
|
+
eda/ marimo notebooks, each rendered to HTML
|
|
86
|
+
modeling/ registered, tested steps, estimators and model classes
|
|
87
|
+
experiments/ ledger.tsv + one E### folder per experiment (config only)
|
|
88
|
+
eval/ frozen splits, metric and scorer, hashed and pinned
|
|
89
|
+
champion/ the one model eligible for promotion
|
|
90
|
+
memory/ brief, state, decisions, session log
|
|
91
|
+
docs/ plans and notes
|
|
92
|
+
utils/ throwaway scripts
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
| Friction | What Supermodel does |
|
|
96
|
+
|---|---|
|
|
97
|
+
| File sprawl | Every folder has one job and its own `CLAUDE.md` contract. New preprocessing, features and models go into registered, tested components in `modeling/`. Experiments are config only, with no Python. Throwaway scripts go in `utils/`, analysis in `eda/`. |
|
|
98
|
+
| Losing track of experiments | `supermodel new-experiment` records the hypothesis and expected effect before anything runs. The runner appends every run to `experiments/ledger.tsv` with its score, noise band and status. `supermodel status` shows the best run, the champion and what's next. |
|
|
99
|
+
| Old code overwritten | Every run commits its inputs to git and records the commit, so later edits never erase how a result was made. `supermodel review E###` links the exact code a run used. Evaluation code, the ledger, results and the champion can't be edited by the agent (enforced by guard hooks in Claude Code). |
|
|
100
|
+
| No way to go back | Each experiment folder keeps its config, hypothesis, notes, log, results and a `protocol.yaml` snapshot of the data and evaluation. Crowns, promotions and design changes are logged with reasons in `memory/decisions.md`. Any run can be rerun from its commit. |
|
|
101
|
+
| Lost context between sessions | `memory/state.md`, the brief, the decision log and the ledger are read at session start. `supermodel wrap-up` (`/wrap-up` in Claude Code) updates them and commits. |
|
|
102
|
+
|
|
103
|
+
### Valid results
|
|
104
|
+
|
|
105
|
+
| Friction | What Supermodel does |
|
|
106
|
+
|---|---|
|
|
107
|
+
| Leakage in preprocessing and early stopping | Model classes bundle steps and estimator into one `fit`/`predict`. The runner passes only training rows to `fit`, including the early-stopping eval set. Every fold set goes through the same leakage checks. |
|
|
108
|
+
| Split, metric or holdout changing under you | `supermodel freeze` builds the splits and hashes `eval/` into a manifest. Every run verifies the pin. After freeze, changing a pinned section blocks runs until the evaluation is unfrozen, which bumps `eval_version`. |
|
|
109
|
+
| Agent-reported scores | Only the runner writes `experiments/ledger.tsv` and `results.json`. |
|
|
110
|
+
| Holdout peeking | The holdout is encrypted at freeze. Only `supermodel promote` decrypts it, scores the crowned champion and records the read. |
|
|
111
|
+
| "Is +0.002 real?" | Each result is compared against `metric_sd`. A gain inside the noise band is reported as inconclusive, not as an improvement. |
|
|
112
|
+
| Setup questionnaires | No interview. Give a sentence, a doc or a data path. The agent infers the configuration, marks each guess `# suggested:`, and freeze refuses until you've accepted each one. |
|
|
113
|
+
|
|
114
|
+
## Why it's useful for ML practitioners
|
|
115
|
+
|
|
116
|
+
**You can run experiments fast without losing rigor.** Ask for an idea in a sentence and the agent implements it, registers it, runs it on the frozen evaluation and reports whether the gain is real.
|
|
117
|
+
|
|
118
|
+
**You keep the judgment calls; the agent does the legwork.** You decide the split, the holdout, the metric and which model gets crowned. The agent writes features, model classes, notebooks and reports, and runs the experiments.
|
|
119
|
+
|
|
120
|
+
**You can always answer "what did we try, and how?"** Every experiment has a hypothesis, a config, a score and a link to its exact code. The ledger is the full history, and nothing in it was typed by the agent.
|
|
121
|
+
|
|
122
|
+
**You get the scaffolding you'd otherwise build yourself.** Most teams eventually write their own CV harness, leakage checks, experiment log, holdout discipline and model packaging. Supermodel ships them as one tested workspace:
|
|
123
|
+
|
|
124
|
+
| You'd normally build | Supermodel gives you |
|
|
125
|
+
|---|---|
|
|
126
|
+
| A cross-validation harness | Frozen, hashed folds: window, rows, period, cutoffs, group, random, column or custom, with gaps, stratification and repeats; `supermodel splits` previews them |
|
|
127
|
+
| Leakage checks | The same checks on every fold set, preprocessing fit on training rows only, rolling-origin forecasts that only see past actuals |
|
|
128
|
+
| An experiment tracker | A ledger written by the runner, one folder per experiment with its hypothesis, config, scores, train-vs-validation gap and a link to the exact code |
|
|
129
|
+
| A test-set policy | An encrypted holdout, read only by `promote`, and every read recorded |
|
|
130
|
+
| Model packaging | One model class per experiment (steps plus estimator) that saves, reloads and scores new data with `supermodel predict` |
|
|
131
|
+
| Analysis hygiene | EDA as marimo notebooks rendered to HTML, saved reviews with versioned score snapshots, plans and notes in `docs/` |
|
|
132
|
+
|
|
133
|
+
**You can pick up where you left off.** State, decisions and the ledger live in plain files in git. A new session, a teammate or a different agent starts from the same picture instead of re-exploring the repo.
|
|
134
|
+
|
|
135
|
+
**It isn't tied to one agent.** The workspace, CLI and runner work with any harness. See [Agent harnesses](#agent-harnesses).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Installation
|
|
140
|
+
|
|
141
|
+
Requires Python ≥ 3.10 and [uv](https://docs.astral.sh/uv/).
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
uv tool install supermodel-ml --with-executables-from marimo
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The package is published on PyPI as [`supermodel-ml`](https://pypi.org/project/supermodel-ml/); the command and the import are both `supermodel`. Plain pip works too: `pip install supermodel-ml`.
|
|
148
|
+
|
|
149
|
+
For the latest code or development:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
uv tool install git+https://github.com/jeffmli/supermodel.git --with-executables-from marimo # latest main
|
|
153
|
+
uv tool install --editable /path/to/supermodel --with-executables-from marimo # from a clone
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Either way this puts `supermodel` and `marimo` on your PATH, and each project's `.venv` gets the same supermodel you installed. The first `supermodel init` also installs the `/init-project` command into Claude Code (`~/.claude/commands/`) if it's missing.
|
|
157
|
+
|
|
158
|
+
## Agent harnesses
|
|
159
|
+
|
|
160
|
+
Everything that protects results lives in the workspace and the CLI, so any agent that can run shell commands can drive a project:
|
|
161
|
+
|
|
162
|
+
- **Any harness.** The frozen evaluation, pin checks, encrypted holdout, runner-written ledger, keep rule and noise band are all enforced by `supermodel` itself. Each project has an `AGENTS.md` (startup, setup workflow, model-development checklist) and a `CLAUDE.md` in every folder describing that folder's contract.
|
|
163
|
+
- **Claude Code** adds guard hooks that block edits to `eval/`, `champion/` and the ledger, permission prompts for freeze, crown, promote and unfreeze, session-start context injection, and slash commands (`/init-project`, `/setup`, `/eda`, `/new-experiment`, `/status`, `/wrap-up`). [`SKILL.md`](SKILL.md) describes how Claude uses the workspace.
|
|
164
|
+
|
|
165
|
+
The examples below use Claude Code. With another harness, start the agent in the project folder and describe what you want to build.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Quick start
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
supermodel init my-project # or run `supermodel init` (or /init-project) inside an existing folder
|
|
173
|
+
cd my-project
|
|
174
|
+
claude
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`init` creates the full skeleton (`data/`, `docs/`, `eda/`, `eval/`, `modeling/`, `experiments/`, `champion/`, `memory/`, `runner/`), a project `.venv`, and a `supermodel.yaml` with `kind: unset`. A `--data` path is read relative to where you run the command.
|
|
178
|
+
|
|
179
|
+
Then work through it in conversation:
|
|
180
|
+
|
|
181
|
+
1. **Say what you want to build.** For example: *"I want to predict which users churn. Data is in data/users.parquet."* Claude runs `/setup`. It profiles the data (schema only), infers the kind and configuration, marks each guess `# suggested:`, and replies with one summary and any open questions.
|
|
182
|
+
2. **Check the evaluation design.** Read the suggested split, holdout and metric in `supermodel.yaml`. Edit or accept them. `supermodel splits` previews the fold table; `supermodel freeze --check` runs every freeze check without writing anything.
|
|
183
|
+
3. **Say "freeze".** Claude runs `supermodel freeze` and Claude Code asks you to approve it. This builds the splits, encrypts the holdout and pins `eval/`.
|
|
184
|
+
4. **Say "run the baseline".** Claude creates E001 and runs it. After every run you get a run card: the result in plain language, compared to the best run and its noise band, with the fold table and links to the record, ledger row and exact code.
|
|
185
|
+
5. **Iterate.** Ask for EDA, features or models in plain language.
|
|
186
|
+
6. **Crown and promote.** "Make E004 the champion" runs `supermodel crown`. "Check it on the holdout" runs `supermodel promote`.
|
|
187
|
+
7. **Say "let's stop here".** `/wrap-up` logs the session, updates `memory/state.md` and commits.
|
|
188
|
+
|
|
189
|
+
### Things you can say
|
|
190
|
+
|
|
191
|
+
| You say | What happens |
|
|
192
|
+
|---|---|
|
|
193
|
+
| "look at the class balance" | `supermodel eda "<question>"` writes a marimo notebook and renders `eda/<name>.html` |
|
|
194
|
+
| "try LightGBM with target encoding" | A new E### with its hypothesis; the step and estimator are registered in `modeling/`, then run |
|
|
195
|
+
| "run a backtest with 3 folds" | `supermodel backtest`, an unofficial development check (works before freeze) |
|
|
196
|
+
| "what's our best model?" | `supermodel status`: best run vs champion, recent runs, next steps |
|
|
197
|
+
| "show me E003's code" | `supermodel review E003` prints the run card and links to the exact code |
|
|
198
|
+
| "make E004 the champion" | `supermodel crown E004 --reason "..."` after your approval |
|
|
199
|
+
| "check it on the holdout" | `supermodel promote` scores the champion once on the sealed holdout |
|
|
200
|
+
| "write up the comparison" | `supermodel report` saves a Markdown review and a versioned score snapshot |
|
|
201
|
+
| "let's stop here" | `/wrap-up` |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Trust modes
|
|
206
|
+
|
|
207
|
+
Set with `trust:` in `supermodel.yaml`, or `supermodel init --trust strict`.
|
|
208
|
+
|
|
209
|
+
- **standard** (default for new projects): no sudo, chmod or passphrase, and it works the same on macOS, Linux and Windows. Guard hooks live in the project's `.claude/settings.json`. The pin and a generated holdout key live in `~/.supermodel`, and the guards keep the agent out of them. Claude runs freeze, crown, promote and unfreeze after you approve each one in Claude Code. This catches mistakes and leakage. It does not stop an agent set on cheating, since a script could reach the key.
|
|
210
|
+
- **strict** (also any project without a `trust:` key): root-owned hooks, pin and managed settings (`sudo supermodel install --project "$PWD"`). The modeler-only commands must run in your own terminal, and the holdout is encrypted with a passphrase you type. `supermodel freeze` shows each suggestion to accept or edit, freezes, asks for the passphrase, then asks for sudo once to install the guards and pin.
|
|
211
|
+
|
|
212
|
+
`supermodel freeze --check` runs every freeze check and writes nothing, in either mode.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Using it in more detail
|
|
217
|
+
|
|
218
|
+
### Model experiments
|
|
219
|
+
|
|
220
|
+
Start a new model with `supermodel new-experiment "<hypothesis>" --expected "<effect>"`. Its folder records the hypothesis and a `protocol.yaml` snapshot of the dataset and planned evaluation. Register the implementation in `modeling/` (supervised: `steps/`, `estimators/`, `model_classes/`; custom: `methods/`) and reference it in the experiment's config. Experiments are config only. Run `supermodel backtest E###` for development or `supermodel run E###` for frozen evaluation.
|
|
221
|
+
|
|
222
|
+
### Splits
|
|
223
|
+
|
|
224
|
+
Supervised folds can be built many ways: window, rows, period, cutoffs, group, random, column or custom, with `order_by`, `keep_apart`, gaps, sliding windows, stratification and repeats. Every fold set goes through the same leakage checks. `supermodel splits` previews the fold table and `supermodel splits --suggest` proposes splits from the data's shape.
|
|
225
|
+
|
|
226
|
+
### Forecasting
|
|
227
|
+
|
|
228
|
+
For forecasts made after each period closes, set `split.horizon` (for example `"1d"`) on a time split. Each validation window is then scored with rolling origins: the runner cuts it into horizon-long blocks and forecasts each with `predict(X, meta, history=...)`, where `history` holds every actual from before that block's origin and nothing later. `supermodel promote` scores the holdout the same way. Without `horizon`, the whole window is forecast from the end of training. Projects frozen before this feature need a re-scaffolded `eval/` before freezing to use it.
|
|
229
|
+
|
|
230
|
+
### Backtests and evaluation reviews
|
|
231
|
+
|
|
232
|
+
`supermodel backtest` reuses the latest successful backtest strategy, starting from the project's inferred settings on the first run. It works before freeze. Each run saves its methodology, selected dev rows or cases, scores and a Markdown report under `experiments/backtests/`.
|
|
233
|
+
|
|
234
|
+
- `supermodel backtest --history` lists strategies.
|
|
235
|
+
- `supermodel backtest E002 --set '{"split":{"n_folds":3}}' --reason "Compare three validation windows"` changes the fold count.
|
|
236
|
+
- `supermodel backtest --strategy ID` restores an older methodology as the default.
|
|
237
|
+
|
|
238
|
+
Backtests are unofficial. Champion selection and holdout promotion keep the frozen evaluation contract, and `supermodel status` only compares backtests within the latest strategy.
|
|
239
|
+
|
|
240
|
+
To save a review: `supermodel report E002 --title "Baseline comparison" --decision "Keep the baseline" --interpretation "..." --next-step "..."`. Each review gets a folder under `memory/reports/` with `report.md` and a versioned `scores.json`, and includes the baseline and current champion automatically. Add `--promotion` to include the recorded holdout result. Regenerate the Markdown with `supermodel report --from-json path/to/scores.json`.
|
|
241
|
+
|
|
242
|
+
### Inference
|
|
243
|
+
|
|
244
|
+
After crowning a supervised experiment, score new rows:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
supermodel predict --data new_rows.csv --out predictions.csv
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
It loads the fitted pipeline from `champion/model/` and accepts CSV or Parquet. Supply the features listed in `champion/model/meta.json`. For a rolling-origin forecaster, add `--history actuals.csv` with the rows whose target is known when the forecast is made.
|
|
251
|
+
|
|
252
|
+
### Notebooks
|
|
253
|
+
|
|
254
|
+
EDA notebooks are [marimo](https://marimo.io) `.py` files in `eda/`. `supermodel eda "<question>"` writes one, runs it, and renders `eda/<name>.html` next to it. Open that file in a browser; there's no server to start. After editing, `supermodel eda --render eda/<name>.py` refreshes the page, and `supermodel notebook eda/<name>.py` opens it interactively in the project's environment.
|
|
255
|
+
|
|
256
|
+
### Project dependencies
|
|
257
|
+
|
|
258
|
+
Each project has its own `.venv` with supermodel, marimo, ipykernel and your declared dependencies. Inside the project, `supermodel` switches to it by itself, so nothing needs activating; VS Code and Jupyter pick it up too. Declare extra packages in `supermodel.yaml`:
|
|
259
|
+
|
|
260
|
+
```yaml
|
|
261
|
+
dependencies:
|
|
262
|
+
- torch>=2.3
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`supermodel env` creates or repairs the environment; re-run it after adding dependencies. `run`, `backtest`, `crown` and `promote` refuse when a declared package is missing and print the install command. `supermodel deps` runs the same check on its own. Re-run it after reinstalling the tool.
|
|
266
|
+
|
|
267
|
+
### Project docs and memory
|
|
268
|
+
|
|
269
|
+
| Where | What |
|
|
270
|
+
|---|---|
|
|
271
|
+
| `docs/plans/` | Plans for upcoming work, one Markdown file per topic; the agent keeps their status current |
|
|
272
|
+
| `docs/notes/` | Data quirks, gotchas, how-tos and references worth keeping |
|
|
273
|
+
| `memory/brief.md` | What the project is for, and open questions |
|
|
274
|
+
| `memory/state.md` | Current best, champion, active hypotheses, next steps |
|
|
275
|
+
| `memory/decisions.md` | Every crown, promotion and design change, with reasons |
|
|
276
|
+
| `memory/sessions/` | Automatic daily session log |
|
|
277
|
+
| `experiments/` | The ledger and one folder per experiment |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Command reference
|
|
282
|
+
|
|
283
|
+
| Command | Purpose |
|
|
284
|
+
|---|---|
|
|
285
|
+
| `supermodel init [NAME]` | Create a blank project (`--trust`, `--data`, `--no-venv`) |
|
|
286
|
+
| `supermodel configure --kind ...` | Set the kind and config (run by `/setup`; repeatable until freeze) |
|
|
287
|
+
| `supermodel profile PATH` | Schema-only profile of a data file |
|
|
288
|
+
| `supermodel check` | Is `supermodel.yaml` complete enough to freeze? |
|
|
289
|
+
| `supermodel splits [--suggest]` | Preview or propose folds |
|
|
290
|
+
| `supermodel freeze [--check]` | Build splits, encrypt the holdout, pin `eval/` |
|
|
291
|
+
| `supermodel verify` | Verify the pin and manifest |
|
|
292
|
+
| `supermodel new-experiment` | Create the next E### folder |
|
|
293
|
+
| `supermodel run E###` | Run one experiment on the frozen evaluation |
|
|
294
|
+
| `supermodel backtest` | Development backtest with a versioned strategy |
|
|
295
|
+
| `supermodel review E###` | Run card and links to an experiment's code |
|
|
296
|
+
| `supermodel status` | Best vs champion, recent runs, next steps |
|
|
297
|
+
| `supermodel crown E### --reason` | Make an experiment the champion |
|
|
298
|
+
| `supermodel promote` | Score the champion on the holdout |
|
|
299
|
+
| `supermodel unfreeze --reason` | Escape hatch: bump `eval_version` |
|
|
300
|
+
| `supermodel predict` | Score new rows with the supervised champion |
|
|
301
|
+
| `supermodel report` | Save a Markdown review and JSON score snapshot |
|
|
302
|
+
| `supermodel eda` / `notebook` | Write, render or open EDA notebooks |
|
|
303
|
+
| `supermodel env` / `deps` | Create the project venv / check declared dependencies |
|
|
304
|
+
| `supermodel wrap-up` | End the session: log, `state.md`, commit |
|
|
305
|
+
| `supermodel selftest` | Run test layers 1–4 |
|
|
306
|
+
|
|
307
|
+
Run `supermodel <command> --help` for the full options.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Examples
|
|
312
|
+
|
|
313
|
+
[`examples/`](examples/README.md) has three runnable projects (churn classification, diabetes regression, store-sales forecasting), each with planted pitfalls. Watch one run end to end, or drive it yourself in Claude Code:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
.venv/bin/python examples/run_demo.py churn # scripted end-to-end run, ~30 s
|
|
317
|
+
.venv/bin/python examples/setup_project.py churn ~/sm-churn
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Develop
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
uv venv --python 3.12 .venv && uv pip install --python .venv/bin/python -e .
|
|
324
|
+
.venv/bin/supermodel selftest # test layers 1-4, ~3 min on CPU
|
|
325
|
+
SUPERMODEL_UPDATE_SNAPSHOTS=1 .venv/bin/supermodel selftest # re-record ledger snapshots after an intended change
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
For a worked ablation study, run `.venv/bin/python -m pytest -q supermodel/tests/test_ablation_workflow.py`. It trains a linear baseline on synthetic data, adds one squared feature, then removes it while keeping the estimator and folds fixed. The test recomputes RMSE from saved predictions and checks that removing the feature recovers baseline performance.
|
|
329
|
+
|
|
330
|
+
`supermodel/testing/` ships the data generators, fake estimators and contract checks, so a new model class can be tested against the same contracts.
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Supermodel
|
|
2
|
+
|
|
3
|
+
**An agent-driven ML workspace. Run ML experiments with a coding agent, trust that the results are valid, and keep the project clean enough to understand months later.**
|
|
4
|
+
|
|
5
|
+
Coding agents (Claude Code, Codex, or any harness that reads `AGENTS.md`) can already write model code. What they don't do on their own is keep an ML project in order. Supermodel gives the agent a structured workspace, a CLI and a set of rules, so you get two things at once:
|
|
6
|
+
|
|
7
|
+
1. **Results you can trust.** The evaluation is frozen and hashed, preprocessing only ever sees training rows, the test set is sealed, and a runner writes every score. The agent never types one.
|
|
8
|
+
2. **A workspace that stays clean.** Every kind of file has one home, every experiment is recorded with its hypothesis, config, score and exact code, and any past result can be traced and rerun.
|
|
9
|
+
|
|
10
|
+
You describe what you want in plain language ("predict which users churn", "try LightGBM with target encoding", "what did we try last week?"). The agent puts each piece in the right folder and runs the right command.
|
|
11
|
+
|
|
12
|
+
Two kinds of project are supported:
|
|
13
|
+
|
|
14
|
+
- **supervised**: classification, regression, ranking and forecasting on tabular data.
|
|
15
|
+
- **custom**: any method (allocation, optimization, simulation) scored by an evaluator you write.
|
|
16
|
+
|
|
17
|
+
See [`docs/spec.md`](docs/spec.md) for the design.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## The problem
|
|
22
|
+
|
|
23
|
+
Point a coding agent at a dataset and ask it to "try a few models", and you get results quickly. A few days later the project looks like this:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
train.py train_v2.py train_lgbm_final.py train_lgbm_final_FIXED.py
|
|
27
|
+
features.py features_new.py eval.py quick_check.py test_split.py
|
|
28
|
+
notebook1.ipynb Untitled3.ipynb results.csv results_old.csv model.pkl
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### The workspace turns into a mess
|
|
32
|
+
|
|
33
|
+
- **File sprawl.** The agent writes a new script for every idea. Throwaway checks, half-finished variants and the code that matters sit side by side.
|
|
34
|
+
- **You lose track of what you tested.** There's no record of which experiments ran, what each one was trying to show, or how it scored.
|
|
35
|
+
- **Old code gets overwritten.** The agent is free to edit any file, including the code behind last week's best result. Once it changes, that result can't be reproduced.
|
|
36
|
+
- **You can't go back.** When someone asks how the current model was built, or why an idea was dropped, the answer is spread across chat logs and stale files.
|
|
37
|
+
|
|
38
|
+
### The results can't be trusted
|
|
39
|
+
|
|
40
|
+
- **Leakage nobody notices.** A scaler is fit on the full dataset, early stopping watches the validation fold, or a feature quietly encodes the target. The score looks great and means nothing.
|
|
41
|
+
- **A moving yardstick.** The split, metric or holdout gets changed between runs, sometimes "to fix a bug". Then E007 and E012 can't be compared.
|
|
42
|
+
- **Numbers typed, not measured.** The agent summarizes a result from memory or a truncated log, and the summary drifts from what actually ran.
|
|
43
|
+
- **Holdout erosion.** Every peek at the test set turns it into one more validation set.
|
|
44
|
+
|
|
45
|
+
You end up re-checking the agent's work line by line and cleaning up after it, which defeats the point of using one.
|
|
46
|
+
|
|
47
|
+
## How Supermodel fixes it
|
|
48
|
+
|
|
49
|
+
### A clean, organized workspace
|
|
50
|
+
|
|
51
|
+
The same project in Supermodel:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
supermodel.yaml task, split, holdout, metric: the evaluation contract
|
|
55
|
+
data/ raw data or a pointer to it
|
|
56
|
+
eda/ marimo notebooks, each rendered to HTML
|
|
57
|
+
modeling/ registered, tested steps, estimators and model classes
|
|
58
|
+
experiments/ ledger.tsv + one E### folder per experiment (config only)
|
|
59
|
+
eval/ frozen splits, metric and scorer, hashed and pinned
|
|
60
|
+
champion/ the one model eligible for promotion
|
|
61
|
+
memory/ brief, state, decisions, session log
|
|
62
|
+
docs/ plans and notes
|
|
63
|
+
utils/ throwaway scripts
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Friction | What Supermodel does |
|
|
67
|
+
|---|---|
|
|
68
|
+
| File sprawl | Every folder has one job and its own `CLAUDE.md` contract. New preprocessing, features and models go into registered, tested components in `modeling/`. Experiments are config only, with no Python. Throwaway scripts go in `utils/`, analysis in `eda/`. |
|
|
69
|
+
| Losing track of experiments | `supermodel new-experiment` records the hypothesis and expected effect before anything runs. The runner appends every run to `experiments/ledger.tsv` with its score, noise band and status. `supermodel status` shows the best run, the champion and what's next. |
|
|
70
|
+
| Old code overwritten | Every run commits its inputs to git and records the commit, so later edits never erase how a result was made. `supermodel review E###` links the exact code a run used. Evaluation code, the ledger, results and the champion can't be edited by the agent (enforced by guard hooks in Claude Code). |
|
|
71
|
+
| No way to go back | Each experiment folder keeps its config, hypothesis, notes, log, results and a `protocol.yaml` snapshot of the data and evaluation. Crowns, promotions and design changes are logged with reasons in `memory/decisions.md`. Any run can be rerun from its commit. |
|
|
72
|
+
| Lost context between sessions | `memory/state.md`, the brief, the decision log and the ledger are read at session start. `supermodel wrap-up` (`/wrap-up` in Claude Code) updates them and commits. |
|
|
73
|
+
|
|
74
|
+
### Valid results
|
|
75
|
+
|
|
76
|
+
| Friction | What Supermodel does |
|
|
77
|
+
|---|---|
|
|
78
|
+
| Leakage in preprocessing and early stopping | Model classes bundle steps and estimator into one `fit`/`predict`. The runner passes only training rows to `fit`, including the early-stopping eval set. Every fold set goes through the same leakage checks. |
|
|
79
|
+
| Split, metric or holdout changing under you | `supermodel freeze` builds the splits and hashes `eval/` into a manifest. Every run verifies the pin. After freeze, changing a pinned section blocks runs until the evaluation is unfrozen, which bumps `eval_version`. |
|
|
80
|
+
| Agent-reported scores | Only the runner writes `experiments/ledger.tsv` and `results.json`. |
|
|
81
|
+
| Holdout peeking | The holdout is encrypted at freeze. Only `supermodel promote` decrypts it, scores the crowned champion and records the read. |
|
|
82
|
+
| "Is +0.002 real?" | Each result is compared against `metric_sd`. A gain inside the noise band is reported as inconclusive, not as an improvement. |
|
|
83
|
+
| Setup questionnaires | No interview. Give a sentence, a doc or a data path. The agent infers the configuration, marks each guess `# suggested:`, and freeze refuses until you've accepted each one. |
|
|
84
|
+
|
|
85
|
+
## Why it's useful for ML practitioners
|
|
86
|
+
|
|
87
|
+
**You can run experiments fast without losing rigor.** Ask for an idea in a sentence and the agent implements it, registers it, runs it on the frozen evaluation and reports whether the gain is real.
|
|
88
|
+
|
|
89
|
+
**You keep the judgment calls; the agent does the legwork.** You decide the split, the holdout, the metric and which model gets crowned. The agent writes features, model classes, notebooks and reports, and runs the experiments.
|
|
90
|
+
|
|
91
|
+
**You can always answer "what did we try, and how?"** Every experiment has a hypothesis, a config, a score and a link to its exact code. The ledger is the full history, and nothing in it was typed by the agent.
|
|
92
|
+
|
|
93
|
+
**You get the scaffolding you'd otherwise build yourself.** Most teams eventually write their own CV harness, leakage checks, experiment log, holdout discipline and model packaging. Supermodel ships them as one tested workspace:
|
|
94
|
+
|
|
95
|
+
| You'd normally build | Supermodel gives you |
|
|
96
|
+
|---|---|
|
|
97
|
+
| A cross-validation harness | Frozen, hashed folds: window, rows, period, cutoffs, group, random, column or custom, with gaps, stratification and repeats; `supermodel splits` previews them |
|
|
98
|
+
| Leakage checks | The same checks on every fold set, preprocessing fit on training rows only, rolling-origin forecasts that only see past actuals |
|
|
99
|
+
| An experiment tracker | A ledger written by the runner, one folder per experiment with its hypothesis, config, scores, train-vs-validation gap and a link to the exact code |
|
|
100
|
+
| A test-set policy | An encrypted holdout, read only by `promote`, and every read recorded |
|
|
101
|
+
| Model packaging | One model class per experiment (steps plus estimator) that saves, reloads and scores new data with `supermodel predict` |
|
|
102
|
+
| Analysis hygiene | EDA as marimo notebooks rendered to HTML, saved reviews with versioned score snapshots, plans and notes in `docs/` |
|
|
103
|
+
|
|
104
|
+
**You can pick up where you left off.** State, decisions and the ledger live in plain files in git. A new session, a teammate or a different agent starts from the same picture instead of re-exploring the repo.
|
|
105
|
+
|
|
106
|
+
**It isn't tied to one agent.** The workspace, CLI and runner work with any harness. See [Agent harnesses](#agent-harnesses).
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Installation
|
|
111
|
+
|
|
112
|
+
Requires Python ≥ 3.10 and [uv](https://docs.astral.sh/uv/).
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
uv tool install supermodel-ml --with-executables-from marimo
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The package is published on PyPI as [`supermodel-ml`](https://pypi.org/project/supermodel-ml/); the command and the import are both `supermodel`. Plain pip works too: `pip install supermodel-ml`.
|
|
119
|
+
|
|
120
|
+
For the latest code or development:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uv tool install git+https://github.com/jeffmli/supermodel.git --with-executables-from marimo # latest main
|
|
124
|
+
uv tool install --editable /path/to/supermodel --with-executables-from marimo # from a clone
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Either way this puts `supermodel` and `marimo` on your PATH, and each project's `.venv` gets the same supermodel you installed. The first `supermodel init` also installs the `/init-project` command into Claude Code (`~/.claude/commands/`) if it's missing.
|
|
128
|
+
|
|
129
|
+
## Agent harnesses
|
|
130
|
+
|
|
131
|
+
Everything that protects results lives in the workspace and the CLI, so any agent that can run shell commands can drive a project:
|
|
132
|
+
|
|
133
|
+
- **Any harness.** The frozen evaluation, pin checks, encrypted holdout, runner-written ledger, keep rule and noise band are all enforced by `supermodel` itself. Each project has an `AGENTS.md` (startup, setup workflow, model-development checklist) and a `CLAUDE.md` in every folder describing that folder's contract.
|
|
134
|
+
- **Claude Code** adds guard hooks that block edits to `eval/`, `champion/` and the ledger, permission prompts for freeze, crown, promote and unfreeze, session-start context injection, and slash commands (`/init-project`, `/setup`, `/eda`, `/new-experiment`, `/status`, `/wrap-up`). [`SKILL.md`](SKILL.md) describes how Claude uses the workspace.
|
|
135
|
+
|
|
136
|
+
The examples below use Claude Code. With another harness, start the agent in the project folder and describe what you want to build.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Quick start
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
supermodel init my-project # or run `supermodel init` (or /init-project) inside an existing folder
|
|
144
|
+
cd my-project
|
|
145
|
+
claude
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`init` creates the full skeleton (`data/`, `docs/`, `eda/`, `eval/`, `modeling/`, `experiments/`, `champion/`, `memory/`, `runner/`), a project `.venv`, and a `supermodel.yaml` with `kind: unset`. A `--data` path is read relative to where you run the command.
|
|
149
|
+
|
|
150
|
+
Then work through it in conversation:
|
|
151
|
+
|
|
152
|
+
1. **Say what you want to build.** For example: *"I want to predict which users churn. Data is in data/users.parquet."* Claude runs `/setup`. It profiles the data (schema only), infers the kind and configuration, marks each guess `# suggested:`, and replies with one summary and any open questions.
|
|
153
|
+
2. **Check the evaluation design.** Read the suggested split, holdout and metric in `supermodel.yaml`. Edit or accept them. `supermodel splits` previews the fold table; `supermodel freeze --check` runs every freeze check without writing anything.
|
|
154
|
+
3. **Say "freeze".** Claude runs `supermodel freeze` and Claude Code asks you to approve it. This builds the splits, encrypts the holdout and pins `eval/`.
|
|
155
|
+
4. **Say "run the baseline".** Claude creates E001 and runs it. After every run you get a run card: the result in plain language, compared to the best run and its noise band, with the fold table and links to the record, ledger row and exact code.
|
|
156
|
+
5. **Iterate.** Ask for EDA, features or models in plain language.
|
|
157
|
+
6. **Crown and promote.** "Make E004 the champion" runs `supermodel crown`. "Check it on the holdout" runs `supermodel promote`.
|
|
158
|
+
7. **Say "let's stop here".** `/wrap-up` logs the session, updates `memory/state.md` and commits.
|
|
159
|
+
|
|
160
|
+
### Things you can say
|
|
161
|
+
|
|
162
|
+
| You say | What happens |
|
|
163
|
+
|---|---|
|
|
164
|
+
| "look at the class balance" | `supermodel eda "<question>"` writes a marimo notebook and renders `eda/<name>.html` |
|
|
165
|
+
| "try LightGBM with target encoding" | A new E### with its hypothesis; the step and estimator are registered in `modeling/`, then run |
|
|
166
|
+
| "run a backtest with 3 folds" | `supermodel backtest`, an unofficial development check (works before freeze) |
|
|
167
|
+
| "what's our best model?" | `supermodel status`: best run vs champion, recent runs, next steps |
|
|
168
|
+
| "show me E003's code" | `supermodel review E003` prints the run card and links to the exact code |
|
|
169
|
+
| "make E004 the champion" | `supermodel crown E004 --reason "..."` after your approval |
|
|
170
|
+
| "check it on the holdout" | `supermodel promote` scores the champion once on the sealed holdout |
|
|
171
|
+
| "write up the comparison" | `supermodel report` saves a Markdown review and a versioned score snapshot |
|
|
172
|
+
| "let's stop here" | `/wrap-up` |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Trust modes
|
|
177
|
+
|
|
178
|
+
Set with `trust:` in `supermodel.yaml`, or `supermodel init --trust strict`.
|
|
179
|
+
|
|
180
|
+
- **standard** (default for new projects): no sudo, chmod or passphrase, and it works the same on macOS, Linux and Windows. Guard hooks live in the project's `.claude/settings.json`. The pin and a generated holdout key live in `~/.supermodel`, and the guards keep the agent out of them. Claude runs freeze, crown, promote and unfreeze after you approve each one in Claude Code. This catches mistakes and leakage. It does not stop an agent set on cheating, since a script could reach the key.
|
|
181
|
+
- **strict** (also any project without a `trust:` key): root-owned hooks, pin and managed settings (`sudo supermodel install --project "$PWD"`). The modeler-only commands must run in your own terminal, and the holdout is encrypted with a passphrase you type. `supermodel freeze` shows each suggestion to accept or edit, freezes, asks for the passphrase, then asks for sudo once to install the guards and pin.
|
|
182
|
+
|
|
183
|
+
`supermodel freeze --check` runs every freeze check and writes nothing, in either mode.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Using it in more detail
|
|
188
|
+
|
|
189
|
+
### Model experiments
|
|
190
|
+
|
|
191
|
+
Start a new model with `supermodel new-experiment "<hypothesis>" --expected "<effect>"`. Its folder records the hypothesis and a `protocol.yaml` snapshot of the dataset and planned evaluation. Register the implementation in `modeling/` (supervised: `steps/`, `estimators/`, `model_classes/`; custom: `methods/`) and reference it in the experiment's config. Experiments are config only. Run `supermodel backtest E###` for development or `supermodel run E###` for frozen evaluation.
|
|
192
|
+
|
|
193
|
+
### Splits
|
|
194
|
+
|
|
195
|
+
Supervised folds can be built many ways: window, rows, period, cutoffs, group, random, column or custom, with `order_by`, `keep_apart`, gaps, sliding windows, stratification and repeats. Every fold set goes through the same leakage checks. `supermodel splits` previews the fold table and `supermodel splits --suggest` proposes splits from the data's shape.
|
|
196
|
+
|
|
197
|
+
### Forecasting
|
|
198
|
+
|
|
199
|
+
For forecasts made after each period closes, set `split.horizon` (for example `"1d"`) on a time split. Each validation window is then scored with rolling origins: the runner cuts it into horizon-long blocks and forecasts each with `predict(X, meta, history=...)`, where `history` holds every actual from before that block's origin and nothing later. `supermodel promote` scores the holdout the same way. Without `horizon`, the whole window is forecast from the end of training. Projects frozen before this feature need a re-scaffolded `eval/` before freezing to use it.
|
|
200
|
+
|
|
201
|
+
### Backtests and evaluation reviews
|
|
202
|
+
|
|
203
|
+
`supermodel backtest` reuses the latest successful backtest strategy, starting from the project's inferred settings on the first run. It works before freeze. Each run saves its methodology, selected dev rows or cases, scores and a Markdown report under `experiments/backtests/`.
|
|
204
|
+
|
|
205
|
+
- `supermodel backtest --history` lists strategies.
|
|
206
|
+
- `supermodel backtest E002 --set '{"split":{"n_folds":3}}' --reason "Compare three validation windows"` changes the fold count.
|
|
207
|
+
- `supermodel backtest --strategy ID` restores an older methodology as the default.
|
|
208
|
+
|
|
209
|
+
Backtests are unofficial. Champion selection and holdout promotion keep the frozen evaluation contract, and `supermodel status` only compares backtests within the latest strategy.
|
|
210
|
+
|
|
211
|
+
To save a review: `supermodel report E002 --title "Baseline comparison" --decision "Keep the baseline" --interpretation "..." --next-step "..."`. Each review gets a folder under `memory/reports/` with `report.md` and a versioned `scores.json`, and includes the baseline and current champion automatically. Add `--promotion` to include the recorded holdout result. Regenerate the Markdown with `supermodel report --from-json path/to/scores.json`.
|
|
212
|
+
|
|
213
|
+
### Inference
|
|
214
|
+
|
|
215
|
+
After crowning a supervised experiment, score new rows:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
supermodel predict --data new_rows.csv --out predictions.csv
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
It loads the fitted pipeline from `champion/model/` and accepts CSV or Parquet. Supply the features listed in `champion/model/meta.json`. For a rolling-origin forecaster, add `--history actuals.csv` with the rows whose target is known when the forecast is made.
|
|
222
|
+
|
|
223
|
+
### Notebooks
|
|
224
|
+
|
|
225
|
+
EDA notebooks are [marimo](https://marimo.io) `.py` files in `eda/`. `supermodel eda "<question>"` writes one, runs it, and renders `eda/<name>.html` next to it. Open that file in a browser; there's no server to start. After editing, `supermodel eda --render eda/<name>.py` refreshes the page, and `supermodel notebook eda/<name>.py` opens it interactively in the project's environment.
|
|
226
|
+
|
|
227
|
+
### Project dependencies
|
|
228
|
+
|
|
229
|
+
Each project has its own `.venv` with supermodel, marimo, ipykernel and your declared dependencies. Inside the project, `supermodel` switches to it by itself, so nothing needs activating; VS Code and Jupyter pick it up too. Declare extra packages in `supermodel.yaml`:
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
dependencies:
|
|
233
|
+
- torch>=2.3
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`supermodel env` creates or repairs the environment; re-run it after adding dependencies. `run`, `backtest`, `crown` and `promote` refuse when a declared package is missing and print the install command. `supermodel deps` runs the same check on its own. Re-run it after reinstalling the tool.
|
|
237
|
+
|
|
238
|
+
### Project docs and memory
|
|
239
|
+
|
|
240
|
+
| Where | What |
|
|
241
|
+
|---|---|
|
|
242
|
+
| `docs/plans/` | Plans for upcoming work, one Markdown file per topic; the agent keeps their status current |
|
|
243
|
+
| `docs/notes/` | Data quirks, gotchas, how-tos and references worth keeping |
|
|
244
|
+
| `memory/brief.md` | What the project is for, and open questions |
|
|
245
|
+
| `memory/state.md` | Current best, champion, active hypotheses, next steps |
|
|
246
|
+
| `memory/decisions.md` | Every crown, promotion and design change, with reasons |
|
|
247
|
+
| `memory/sessions/` | Automatic daily session log |
|
|
248
|
+
| `experiments/` | The ledger and one folder per experiment |
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Command reference
|
|
253
|
+
|
|
254
|
+
| Command | Purpose |
|
|
255
|
+
|---|---|
|
|
256
|
+
| `supermodel init [NAME]` | Create a blank project (`--trust`, `--data`, `--no-venv`) |
|
|
257
|
+
| `supermodel configure --kind ...` | Set the kind and config (run by `/setup`; repeatable until freeze) |
|
|
258
|
+
| `supermodel profile PATH` | Schema-only profile of a data file |
|
|
259
|
+
| `supermodel check` | Is `supermodel.yaml` complete enough to freeze? |
|
|
260
|
+
| `supermodel splits [--suggest]` | Preview or propose folds |
|
|
261
|
+
| `supermodel freeze [--check]` | Build splits, encrypt the holdout, pin `eval/` |
|
|
262
|
+
| `supermodel verify` | Verify the pin and manifest |
|
|
263
|
+
| `supermodel new-experiment` | Create the next E### folder |
|
|
264
|
+
| `supermodel run E###` | Run one experiment on the frozen evaluation |
|
|
265
|
+
| `supermodel backtest` | Development backtest with a versioned strategy |
|
|
266
|
+
| `supermodel review E###` | Run card and links to an experiment's code |
|
|
267
|
+
| `supermodel status` | Best vs champion, recent runs, next steps |
|
|
268
|
+
| `supermodel crown E### --reason` | Make an experiment the champion |
|
|
269
|
+
| `supermodel promote` | Score the champion on the holdout |
|
|
270
|
+
| `supermodel unfreeze --reason` | Escape hatch: bump `eval_version` |
|
|
271
|
+
| `supermodel predict` | Score new rows with the supervised champion |
|
|
272
|
+
| `supermodel report` | Save a Markdown review and JSON score snapshot |
|
|
273
|
+
| `supermodel eda` / `notebook` | Write, render or open EDA notebooks |
|
|
274
|
+
| `supermodel env` / `deps` | Create the project venv / check declared dependencies |
|
|
275
|
+
| `supermodel wrap-up` | End the session: log, `state.md`, commit |
|
|
276
|
+
| `supermodel selftest` | Run test layers 1–4 |
|
|
277
|
+
|
|
278
|
+
Run `supermodel <command> --help` for the full options.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Examples
|
|
283
|
+
|
|
284
|
+
[`examples/`](examples/README.md) has three runnable projects (churn classification, diabetes regression, store-sales forecasting), each with planted pitfalls. Watch one run end to end, or drive it yourself in Claude Code:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
.venv/bin/python examples/run_demo.py churn # scripted end-to-end run, ~30 s
|
|
288
|
+
.venv/bin/python examples/setup_project.py churn ~/sm-churn
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Develop
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
uv venv --python 3.12 .venv && uv pip install --python .venv/bin/python -e .
|
|
295
|
+
.venv/bin/supermodel selftest # test layers 1-4, ~3 min on CPU
|
|
296
|
+
SUPERMODEL_UPDATE_SNAPSHOTS=1 .venv/bin/supermodel selftest # re-record ledger snapshots after an intended change
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
For a worked ablation study, run `.venv/bin/python -m pytest -q supermodel/tests/test_ablation_workflow.py`. It trains a linear baseline on synthetic data, adds one squared feature, then removes it while keeping the estimator and folds fixed. The test recomputes RMSE from saved predictions and checks that removing the feature recovers baseline performance.
|
|
300
|
+
|
|
301
|
+
`supermodel/testing/` ships the data generators, fake estimators and contract checks, so a new model class can be tested against the same contracts.
|