Skip to main content

Saber

PyPI PyVersions Tests License

Saber is a Python library for classical supervised machine learning (classification and regression) on numerical tabular features. It trains, validates, tunes, benchmarks and persists scikit-learn, XGBoost and LightGBM models, with preprocessing fitted inside each fold and every result tied back to its samples, partition and parameters.

Saber doesn't compute features. Bring a descriptor table, an embedding or any numeric matrix, and Saber models it. Deep learning, AutoML, multilabel and multi-output problems are out of scope.

Installation

Saber supports Python 3.11 to 3.14.

python -m pip install saberlib

Optional extras:

python -m pip install "saberlib[biosieve]"   # partition generation
python -m pip install "saberlib[optuna]"     # Optuna tuning
python -m pip install "saberlib[xgboost]"    # XGBoost models
python -m pip install "saberlib[lightgbm]"   # LightGBM models
python -m pip install "saberlib[all]"

For development setup with uv, see DEVELOPMENT.md.

Validate a model

import numpy as np
from sklearn.datasets import make_classification

import saber
from saber import DatasetBundle, PartitionPlan

X, y = make_classification(n_samples=120, n_features=12, random_state=42)
dataset = DatasetBundle(X=X, y=y, sample_ids=[f"s{i}" for i in range(len(y))])

plan = PartitionPlan.from_predefined_folds(
    sample_ids=dataset.sample_ids,
    fold_assignments=np.arange(len(y)) % 4,
    dataset=dataset,
)

result = saber.validate(
    dataset=dataset,
    algorithm="logistic_regression",
    partition_plan=plan,
    metrics=("mcc", "balanced_accuracy", "roc_auc"),
    random_state=42,
)
print(result.aggregate_metrics)

result.oof_prediction holds the out-of-fold predictions, aligned by sample ID. X can be a NumPy array, a Polars DataFrame or a pandas DataFrame. Partitions refer to samples by ID, never by row position. If your data isn't split yet, let BioSieve generate the partitions:

from saber import BioSievePartitionConfig

result = saber.validate(
    dataset=dataset,
    algorithm="random_forest_classifier",
    partition_plan=BioSievePartitionConfig(
        strategy="stratified_kfold",
        params={"n_splits": 5, "seed": 42},
    ),
    metrics=("mcc", "roc_auc"),
)

The data and partitions guide covers holdouts, external partition files and BioSieve.

Tune, benchmark and save

from saber import Categorical, LogFloat, SearchSpace, TuningConfig

tuned = saber.tune(
    dataset=dataset,
    algorithm="svc",
    partition_plan=plan,
    search_space=SearchSpace(
        parameters={"C": LogFloat(1e-3, 1e2), "kernel": Categorical(["linear", "rbf"])},
    ),
    config=TuningConfig(optimizer="random", n_trials=20),
    metrics=("mcc",),
    random_state=42,
)
print(tuned.best_params)

saber.benchmark(...) crosses representations, partitions, algorithms, seeds and tuned/untuned modes, and returns long-form Polars tables of metrics and per-sample predictions. saber.train(...) fits a final model, and saber.save_model(path, result, dataset=dataset) writes a train or tune result as a directory with a feature schema, provenance and checksums that saber.load_model(...) verifies before loading. See the tuning, benchmarking and persistence guides.

Command line

saber models list --task classification
saber run experiment.yaml --dry-run
saber run study.yaml --json
saber artifact verify artifacts/model

Every workflow can be written as a YAML or JSON file and run from the CLI or with saber.run_config("experiment.yaml"). See the configuration and CLI references.

Design principles

  • Imputation and scaling are fitted inside each training fold, never on the whole dataset.
  • Existing partitions are used exactly as given. New ones come from BioSieve; Saber has no splitters of its own.
  • Tuned results are reported on a protected test set, not on the folds used to pick the hyperparameters.
  • For binary problems the positive class is explicit, never inferred from a probability column's position.
  • Saved models carry dataset and partition fingerprints and are checksum verified before loading. They use joblib, so load them only from trusted sources.

Saber keeps the workflow honest, but it can't tell whether your partitions or metrics answer your scientific question, or catch leakage that happened upstream.

Documentation and examples

The documentation index links all the guides. There are also 13 example notebooks written in marimo. To open one:

uv sync --all-extras --group examples
uv run marimo edit examples/01_binary_classification.py

Citing and license

If you use Saber in published work, please cite it using CITATION.cff, or the "Cite this repository" button on GitHub. Saber is released under the MIT license.

Metadata

Release files for saberlib 0.1.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 saberlib 0.1.0
File Size Uploaded Provenance Actions
saberlib-0.1.0.tar.gz 80.3 kB With provenance Details for saberlib-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for saberlib 0.1.0
File Interpreter ABI Platform Actions
saberlib-0.1.0-py3-none-any.whl Python 3 none any Details for saberlib-0.1.0-py3-none-any.whl

Total release size: 192.2 kB

Release files / saberlib-0.1.0.tar.gz

Download URL saberlib-0.1.0.tar.gz
Size 80.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7cfb38603ed5e8bd82e3e884747c5b7f9efb8f7344ff2d96304ce8e90427b381
BLAKE2b-256 checksum
How to use checksums
ea783fe68b40694cd11a0e2c763e3785329c8fb5a82bb15ad05fc0bae24dbb4d
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 5, 2026.

Transparency log

Release files / saberlib-0.1.0-py3-none-any.whl

Download URL saberlib-0.1.0-py3-none-any.whl
Size 111.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1213d6df66502656c2eddd79004029331dad42af73a8e8741001d42babbaf2fe
BLAKE2b-256 checksum
How to use checksums
5ec77dc199047b2b69c5939834ae555aeff09db325124455908d876f73f24795
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 5, 2026.

Transparency log

Security for saberlib 0.1.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for saberlib-0.1.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 Oct 5, 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