For ML engineers

Map the pipeline. Find the dead experiments.

Every ML repo has two codebases: the pipeline that actually runs, and the graveyard of train_v1_legacy, grid_search_old, and _fit_experimental that nothing calls anymore. A verified call graph separates them in seconds — without importing torch, sklearn, or your data.

ingest → features → train → evaluate check --dead-code no ML libs needed

Commands below run against an ML-shaped fixture in the repo (examples/scenarios/ml_pipeline — a live run → ingest → features → train → evaluate pipeline plus deliberately orphaned experiment code). Output is verbatim.

1

See the pipeline that actually runs

$ py-code-visualizer visualize examples/scenarios/ml_pipeline -o pipeline.html
Built graph with 16 functions and 13 calls Interactive HTML visualization saved to pipeline.html

Canonical stats: 16 functions, 13 calls, 0 cycles, 0 ambiguous edges — in one self-contained offline file. The map shows one clean spine from pipeline.run through each stage — and an island of experiment functions connected to nothing. That island is your cleanup backlog, made visible.

2

List the graveyard, with proof

$ py-code-visualizer check examples/scenarios/ml_pipeline --dead-code
✅ Architecture check passed: no rule or cycle violations. 🟡 2 function(s) with no in-project callers (review — may be public API): experiments.grid_search_abandoned experiments.train_model_v1_legacy

Deliberately conservative: _fit_legacy is not listed even though it's effectively dead, because the (dead) legacy trainer still calls it — the tool reports what it can prove, and once you delete the trainer, the next run flags its helper too. A review list you can trust, not a chainsaw.

3

Refactor the training loop with an agent — safely

"Refactor train_model to support checkpointing" is a classic agent task. Give the agent verified facts about who calls it and what it calls, instead of letting it guess from a repo dump:

$ py-code-visualizer context examples/scenarios/ml_pipeline --focus train_model
# Context Pack — ml_pipeline - Focus: `train.train_model` - Included functions: 13 ## Verified calls (caller → callee · confidence · provenance) - `pipeline.run` → `train.train_model` · resolved · …/pipeline.py:12 - `train.train_model` → `train._fit` · resolved · …/train.py:6 - `train.train_model` → `train._hyperparams` · resolved · …/train.py:5 …

The agent knows — with provenance — that only pipeline.run depends on the signature it's about to change. See the full agent-context walkthrough.

What you got. The live pipeline mapped and separated from the experiment graveyard (2 orphaned functions found here, each with a file:line), zero dependencies installed, and verified context for AI-assisted refactoring of the training loop. The mess every ML repo carries, finally measurable.

Fixture: examples/scenarios/ml_pipeline. Output shown verbatim except lists trimmed with … and repeated path prefixes shortened to …/ for width. Scales: a measured 98,669-line project maps in ~4.9 s.

← All use cases