TrainLens
See what changed between training runs without leaving your notebook.
TrainLens is a lightweight Python library for comparing training runs, spotting common training problems, planning the next experiment, exporting results, and optionally asking an OpenAI-compatible model to explain the evidence.
Try it in a notebook in 20 seconds
First cell:
%pip install -q trainlens
Second cell:
from trainlens import compare_runs
compare_runs(
{"loss": 0.52, "accuracy": 0.84},
{"loss": 0.41, "accuracy": 0.89},
baseline_name="baseline",
experiment_name="new run",
)
That is enough. In Jupyter, TrainLens renders the result as Markdown automatically:
Summary
- Material improvement detected in accuracy, loss.
Metric Baseline Experiment Delta Direction accuracy 0.84 0.89 +0.05 improved loss 0.52 0.41 -0.11 improved
No model provider, API key, callback, or experiment tracker is required for local comparison.
A few useful snippets
Keep the structured result when you want to inspect it in code:
comparison = compare_runs(old_metrics, new_metrics)
comparison.improvements
comparison.regressions
Render the same comparison anywhere Markdown is useful:
markdown = comparison.to_markdown()
print(markdown)
Export a comparison to another format:
from trainlens import render_report
html = render_report(comparison, format="html")
json_text = render_report(comparison, format="json")
TrainLens also understands richer TrainingRun objects, including metric trajectories and
configuration changes, when you need more than two dictionaries.
What else can TrainLens do?
- Compare runs with metric-aware improvement/regression semantics.
- Inspect notebook training context without wiring a full MLOps stack.
- Monitor training with built-in and extensible alert detectors.
- Plan the next experiment with constraints, objectives, and Pareto-aware helpers.
- Save and load portable runs for repeatable comparisons.
- Export reports to Markdown, JSON, HTML, and optional PDF.
- Use an optional LLM to explain deterministic TrainLens findings through any OpenAI-compatible endpoint, including local servers.
The local analysis features are deterministic and do not make an LLM request.
Want the deeper API?
The README intentionally stays small. The versioned docs contain the advanced workflows:
- Getting started
- Notebook workflows
- Python API
- Monitoring
- LLM setup and privacy
- Exports and troubleshooting
- Documentación en español
Privacy
LLM support is optional. When enabled, TrainLens minimizes and bounds notebook evidence, redacts secrets, and keeps notebook-derived evidence separate from trusted system instructions. Treat generated explanations as assistance and verify them against the underlying training evidence.
Scope
TrainLens is a lightweight notebook reporting and experiment-understanding layer, not a full MLOps platform. It is designed for research and small-to-medium workflows where the important training context already lives in Python and Jupyter.
Contributing and license
See CONTRIBUTING.md to contribute and SECURITY.md to report vulnerabilities.
TrainLens is licensed under the Apache License 2.0.
Metadata
Release files for trainlens 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trainlens-0.12.0.tar.gz | 123.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trainlens-0.12.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 215.7 kB
Release files / trainlens-0.12.0.tar.gz
| Download URL | trainlens-0.12.0.tar.gz |
|---|---|
| Size | 123.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f157ec72e90a2d390738b31326ee0d3d352740af7d6cbaa1051a24d522f9fa4
|
|
BLAKE2b-256 checksum How to use checksums |
57e25b305f39153111144727b4ec8f82619134ef820fadbfaa9e9f0446fe24e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / trainlens-0.12.0-py3-none-any.whl
| Download URL | trainlens-0.12.0-py3-none-any.whl |
|---|---|
| Size | 91.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e78b27c9bb52c996552215b8aed640b67c1d4d769e98fbea64dc20faabc1009
|
|
BLAKE2b-256 checksum How to use checksums |
efd4fbd9425dcb26a337ddf043939c5ab50af90c54dc62bbfacd81589079b0a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency log