Getting Started
Install OchreML and train your first hardware-accelerated Classical ML model in seconds.
OchreML brings 63 Scikit-Learn-compatible Classical ML estimators, preprocessing utilities, pipelines, and cross-device .dit persistence backed by a single Rust engine. Every wheel is self-contained (~21.8 MB) with zero required Python runtime dependencies. (^▽^)
Installation
Install the prebuilt wheel from PyPI:
pip install ochremlIf you use uv:
uv pip install ochremlNumPy is optional — OchreML accepts Python lists, memoryview, and NumPy arrays seamlessly via the zero-copy Python Buffer Protocol. Installing numpy enables zero-copy contiguous f64 array ingestion and NumPy outputs.
Building from Source
Requires Rust (edition = "2024") and maturin:
git clone https://github.com/arufadesuwa/ochreml.git
cd ochreml
maturin develop --releaseDefault Cargo features (cuda-dynamic, wgpu-backend, tpu-pjrt) compile on any standard machine without CUDA or TPU SDKs installed because CUDA and TPU libraries are loaded dynamically at runtime.
Quickstart
1. Check Available Hardware
OchreML automatically probes CPU cores, NVIDIA CUDA GPUs, wgpu adapters (Vulkan/Metal/DX12), and Google Cloud TPUs:
import ochreml
print("Version:", ochreml.__version__)
print("Available devices:", ochreml.get_available_devices())
print("Hardware info:", ochreml.get_device_info())2. Fit, Predict, and Score
Every estimator follows the familiar fit / predict / score API and defaults to device="auto", which selects the fastest available accelerator or falls back cleanly to Rayon-parallel CPU (f64):
from ochreml.linear_model import Ridge
from ochreml.model_selection import train_test_split
from ochreml.metrics import r2_score
X = [[1.0, 2.0], [2.0, 1.0], [3.0, 4.0], [4.0, 3.0], [5.0, 6.0], [6.0, 5.0]]
y = [5.0, 4.0, 11.0, 10.0, 17.0, 16.0]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
model = Ridge(alpha=0.1, device="auto")
model.fit(X_train, y_train)
preds = model.predict(X_test)
print("R2:", r2_score(y_test, preds))3. Build a Pipeline and Save to .dit
Chain preprocessing and estimators in a Pipeline, persist to a compact .dit binary file, and reload on any target device:
import ochreml
from ochreml.pipeline import make_pipeline
from ochreml.preprocessing import StandardScaler
from ochreml.ensemble import HistGradientBoostingClassifier
pipe = make_pipeline(
StandardScaler(),
HistGradientBoostingClassifier(max_iter=100, device="auto"),
)
pipe.fit(X_train, y_train_cls)
# Persist individual estimators or pipelines to .dit
ochreml.save(pipe, "classifier.dit")
# Reload on CPU or another accelerator
loaded = ochreml.load("classifier.dit", device="cpu")
preds = loaded.predict(X_test)Next Steps
1-Line Scikit-Learn Migration
Swap sklearn imports for ochreml with minimal or zero code changes.
Hardware Acceleration
Configure CPU Rayon, CUDA/Multi-GPU cuda:all, wgpu, and Google Cloud TPU.
Linear, GLM & Linear SVM
Explore dedicated API docs for all 63 Classical ML estimators grouped by family.
Multi-Hardware Benchmarks
Inspect real CPU 4c and CUDA 2xGPU speedups versus scikit-learn.