Getting Started
This guide will get you up and running with KladML in under 5 minutes.
Installation
This installs:
- The
kladmlPython package - MLflow for experiment tracking
- CLI commands (
kladml init,kladml run, etc.)
Verify Installation
Create Your First Project
This creates:
my-project/
├── kladml.yaml # Project configuration
├── train.py # Example training script
├── data/ # Dataset directory
├── models/ # Saved models
└── experiments/ # Experiment outputs
Run Training
Option 1: Native (Development)
Run directly with your local Python environment:
Best for development
Native mode is fastest for iterating on your code. No Docker required.
Option 2: Containerized (Reproducibility)
Run inside a Docker/Podman container:
GPU Support
For CUDA, use --device cuda. The container automatically uses the GPU image.
Create a Model
Here's a minimal example:
from kladml import TimeSeriesModel
class MyForecaster(TimeSeriesModel):
def train(self, X_train, y_train=None, **kwargs):
"""Train the model. Return metrics dict."""
# Your training logic here
self.weights = ...
return {"loss": 0.1, "epochs": 10}
def predict(self, X, **kwargs):
"""Generate predictions."""
return self.weights @ X
def evaluate(self, X_test, y_test=None, **kwargs):
"""Evaluate on test data. Return metrics dict."""
predictions = self.predict(X_test)
return {"mae": abs(predictions - y_test).mean()}
def save(self, path: str):
"""Save model to directory."""
import json
with open(f"{path}/weights.json", "w") as f:
json.dump(self.weights.tolist(), f)
def load(self, path: str):
"""Load model from directory."""
import json
with open(f"{path}/weights.json") as f:
self.weights = json.load(f)
Use the ExperimentRunner
The ExperimentRunner handles:
- Creating MLflow runs
- Logging parameters and metrics
- Saving artifacts
- Managing the training lifecycle
from kladml import ExperimentRunner
runner = ExperimentRunner()
result = runner.run(
model_class=MyForecaster,
train_data=(X_train, y_train),
test_data=(X_test, y_test),
experiment_name="my-experiment",
params={"learning_rate": 0.01}
)
print(f"Run ID: {result['run_id']}")
print(f"Metrics: {result['metrics']}")
View Experiments
KladML uses MLflow for tracking. View your experiments:
Open http://localhost:5000 in your browser.
Next Steps
- Core Concepts - Understand interfaces and architecture
- Architecture - Deep dive into model contracts
- CLI Reference - All available commands