Skip to main content

ml-labs

A structured machine learning experimentation framework for building, managing, and evaluating ML pipelines with cross-validation, caching, and multi-framework support.

Installation

pip install ml-labs

With optional dependencies:

pip install ml-labs[xgboost]    # XGBoost support
pip install ml-labs[lightgbm]   # LightGBM support
pip install ml-labs[catboost]   # CatBoost support
pip install ml-labs[shap]       # SHAP value analysis
pip install ml-labs[polars]      # Polars DataFrame support
pip install ml-labs[tensorflow]  # Neural network estimators (NNClassifier, NNRegressor)
pip install ml-labs[all]         # All optional dependencies

Key Features

  • Project: Owns the directory layout and what is project-wide — pipelines, Collectors, the Trial store, the shared cache
  • PipelineBuilder → Pipeline: A mutable builder producing an immutable node graph; definitions are declarations, resolved only at execution time
  • Experimenter: Evaluates Trials — candidate models — with nested cross-validation, caching and error resilience
  • Trainer: Trains Predictors — the candidates you chose — and exports a standalone Inferencer
  • Collectors: Extensible collection — metrics, stacking outputs, model attributes, SHAP values, raw outputs — with a per-fold history of what each one did
  • Adapters: Unified interface for scikit-learn, XGBoost, LightGBM, CatBoost and Keras
  • Data Flexibility: pandas, polars, cuDF and NumPy arrays

Architecture Overview

Project ─────────── directory layout + pipelines, Collectors, TrialStore, cache
  │
  ├─ PipelineBuilder ──build()──► Pipeline    preprocessing nodes only
  │
  ├─ Experimenter ─── evaluates Trials, fold by fold          exp/{name}/
  │
  └─ Trainer ──────── trains Predictors on full data      trainers/{name}/
        │
        └─ to_inferencer() ──► Inferencer     standalone at serve time

Each run keeps its splitter, its adopted Pipeline and its artifacts in its own directory, and reopens from that path alone — no Project required.

Node State Model:

init ──→ built
  ▲
  └──→ error ──→ (reset_nodes) ──→ init

Quick Start

from mllabs import Project, Trial, Connector

project = Project('exp')

p = project.pipeline_builder('main')
p.set_datasource({'age': 'numerical', 'income': 'numerical', 'target': 'binary'},
                 targets=['target'])
p.set_node('scale', processor='sklearn.preprocessing.StandardScaler',
           method='fit_transform', edges={'X': '{age, income}'})

e = project.experimenter('cv', df, pipeline_name='main',
                         pipeline_version=project.build_pipeline(p).version)
e.build()

collectors = project.collectors()
collectors.set_collector(
    'acc', 'mllabs.collector.MetricCollector',
    {'__ref__': 'mllabs.Connector', '__params__': {'edges': {'y': '{target}'}}},
    params={'output_var': '-1:',
            'metric_func': {'__callable__': 'sklearn.metrics.accuracy_score'}})

trials = [Trial(f'lr_{c}', 'sklearn.linear_model.LogisticRegression',
                {'X': 'scale:(*)', 'y': '{target}'}, method='predict',
                params={'C': c})
          for c in (0.1, 1.0)]

e.exp([(t, 0, 0) for t in trials], project.trials, collectors=collectors)

print(collectors.get_collector('acc').get_metrics_agg(None)[0])

Documentation

Full documentation is available at https://sunkusun9.github.io/ml-labs/

  • Concepts — Architecture, Pipeline, State model, Data flow
  • User Guide — Project & Pipeline, edges DSL, Experimenter & Trials, Trainer & Collectors, Adapters, Processors, Neural Networks
  • Serving Guide — Inferencer export and inference
  • API Reference — Full API reference

Requirements

  • Python >= 3.10
  • pandas >= 1.5
  • numpy >= 1.23
  • scikit-learn >= 1.2
  • cachetools >= 5.0

License

PolyForm Noncommercial 1.0.0 — free for non-commercial use.

Metadata

Release files for ml-labs 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ml-labs 0.9.0
File Size Uploaded Provenance Actions
ml_labs-0.9.0.tar.gz 197.3 kB With provenance Details for ml_labs-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ml-labs 0.9.0
File Interpreter ABI Platform Actions
ml_labs-0.9.0-py3-none-any.whl Python 3 none any Details for ml_labs-0.9.0-py3-none-any.whl

Total release size: 360.1 kB

Release files / ml_labs-0.9.0.tar.gz

Download URL ml_labs-0.9.0.tar.gz
Size 197.3 kB
Tags Source
SHA-256 checksum
How to use checksums
257067efcead444aac699008e237124a2db20273fa90df9007501b9b97247cda
BLAKE2b-256 checksum
How to use checksums
2ef1c4a3b1be59dacdb9fde1d2c33a87c7637208eb63334c21bfb7b30b7ea539
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 Aug 4, 2026.

Transparency log

Release files / ml_labs-0.9.0-py3-none-any.whl

Download URL ml_labs-0.9.0-py3-none-any.whl
Size 162.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e4f61614e474ba0f75f2512a66e938e3f31cb1f554c4dbcf966f130009ba65d
BLAKE2b-256 checksum
How to use checksums
dcf1aa86f32012b4de2419fe527b56c6034e10169ba35914618d008afb8b24cd
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 Aug 4, 2026.

Transparency log

Security for ml-labs 0.9.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ml_labs-0.9.0.tar.gz

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 Aug 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page