A scientific-method harness for AI-driven ML training: experiment ledger, hypothesis gates, diagnostics, and data-verdict reports over MCP.
Project description
MLLoop
A scientific-method harness for AI-driven machine learning.
Coding agents (Claude Code, opencode, ...) can already write training code and run ten variants overnight. What they don't do by themselves is science: diagnose why a model underperforms, form falsifiable hypotheses, run discriminating experiments, and — when the data itself is the problem — produce evidence strong enough to convince stakeholders.
MLLoop is an MCP server that sits between the agent and your training code and enforces that loop at the tool layer, not via prompts:
- Experiment ledger — every run, hypothesis, and decision recorded in SQLite plus an
append-only JSONL event log, all under
.mlloop/in your project. - Hypothesis gate —
run_startrefuses any experiment that doesn't test a registered, falsifiable hypothesis. No hypothesis, no run. - Artifact contract — each run writes standardized
predictions.parquet+meta.json; diagnostics never read your training code, so any framework works. - Diagnostics battery — after every run: error slices, bootstrap noise floor ("what delta counts as evidence"), confusion/residuals, calibration, the operating curve (overkill vs catch rate, with degenerate-prediction detection), a SHAP explanation of missed positives (are they feature-limited or learnable?), and the overfit gap. Diagnosing the previous run is itself a gate: no diagnosis, no next experiment.
- Data Verdict Report — when runs stagnate,
forensics_runinterrogates the dataset with independent probes (shuffled-label signal check, confident-learning label-noise estimation, conflicting-duplicate bound, learning curve, per-feature signal) andreport_generaterenders a stakeholder-readable HTML verdict: is the ceiling set by the data or by the modeling? Demo: inject 20% label noise into a clean dataset — the report catches it, quantifies it, and lists the suspect rows. - Domain context —
context_registerrecords what columns MEAN in domain terms (learned from dataset docs, domain MCP servers/skills, or the user); error slices and reports become domain-readable, and every report ships a data dictionary. - FE-opportunity probe —
fe_probeprices feature engineering before you spend runs on it: screens arithmetic combinations and stacked-model features for incremental signal with a paired, multiple-testing-adjusted significance bar. The probe generates hypotheses; the ledger tests them. - Custom metrics — a domain metric (AMS, weighted cost, ...) plugs in as a python
file defining
metric(predictions) -> float(goal_define(metric_script=...)ormetric_register); the noise floor is then computed in the metric's real units.goal_definealso refuses task-mismatched metrics and flags accuracy-on-imbalance with an advisory. - Dashboard — "The Lab Ledger": lineage tree with hypothesis-labeled edges, metric
journey with target line and noise-floor band, a narrated overnight log, evidence
rail, and per-run dossiers — built for the morning-after review of an overnight
autonomous session. The MCP server auto-opens it in your browser on the first tool
call (
MLLOOP_NO_DASHBOARD=1to disable);mlloop dashboardserves it manually.
Status: Phase 2 — ledger, gates, diagnostics, forensics, reports, and dashboard. Full design: DESIGN.md. Agent setup (Claude Code / opencode / Codex): docs/integrations.md.
Quickstart
pip install -e .
cd your-ml-project
mlloop init --agent claude # or opencode / codex / all — writes the MCP config
Then tell your agent to train a model. The enforced workflow:
| Step | Tool | Gate |
|---|---|---|
| 1 | goal_define |
Locks dataset, target column, primary metric. Required first. |
| 2 | run_start(kind='baseline') |
First run must be a simple baseline. |
| 3 | diagnose_run |
Every finished run must be diagnosed before the next experiment. |
| 4 | hypothesis_register |
Falsifiable claim about what limits performance, from the diagnosis. |
| 5 | run_start(hypothesis_id=...) |
Refused without a registered hypothesis. |
| 6 | run_finish |
Validates the artifact contract before accepting results. |
| 7 | hypothesis_resolve / decision_record |
Evidence-backed resolution, recorded decisions. |
| 8 | forensics_run → report_generate |
When stagnating: interrogate the data, render the verdict. |
status shows the current state and allowed actions at any time; ledger_query restores
full context after an agent restart or context compaction.
Contributing
Issues, design feedback, and pull requests are welcome — see CONTRIBUTING.md. Please note the Code of Conduct.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlloop-0.0.3.tar.gz.
File metadata
- Download URL: mlloop-0.0.3.tar.gz
- Upload date:
- Size: 82.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ef51d092017d4dee9146c86f86210cf3ecac2bf069cc8d3c78959a69a021cf
|
|
| MD5 |
8666ac8f4d43152f7b58a26c1366f285
|
|
| BLAKE2b-256 |
65ae951db31ec0fd16a1504f80709eaa7b635d188aa8249079285ad1b45b1d29
|
Provenance
The following attestation bundles were made for mlloop-0.0.3.tar.gz:
Publisher:
publish.yml on Sin991114/mlloop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlloop-0.0.3.tar.gz -
Subject digest:
15ef51d092017d4dee9146c86f86210cf3ecac2bf069cc8d3c78959a69a021cf - Sigstore transparency entry: 2142700539
- Sigstore integration time:
-
Permalink:
Sin991114/mlloop@fceca31f360c2b6fef8d86c58c34dfd2a74c364c -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/Sin991114
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fceca31f360c2b6fef8d86c58c34dfd2a74c364c -
Trigger Event:
release
-
Statement type:
File details
Details for the file mlloop-0.0.3-py3-none-any.whl.
File metadata
- Download URL: mlloop-0.0.3-py3-none-any.whl
- Upload date:
- Size: 67.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c6cecde5539f792eb35321726a0db76db0a368c68ee0c90daa3a0eed2cbcac2
|
|
| MD5 |
3ec9592da9cdd65fa459b73864a2c78c
|
|
| BLAKE2b-256 |
f03069157a54a1f9a6a38e57a8e259336a3cdf224f1b9fb89d4502b3fe79f5d1
|
Provenance
The following attestation bundles were made for mlloop-0.0.3-py3-none-any.whl:
Publisher:
publish.yml on Sin991114/mlloop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlloop-0.0.3-py3-none-any.whl -
Subject digest:
6c6cecde5539f792eb35321726a0db76db0a368c68ee0c90daa3a0eed2cbcac2 - Sigstore transparency entry: 2142700550
- Sigstore integration time:
-
Permalink:
Sin991114/mlloop@fceca31f360c2b6fef8d86c58c34dfd2a74c364c -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/Sin991114
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fceca31f360c2b6fef8d86c58c34dfd2a74c364c -
Trigger Event:
release
-
Statement type: