Skip to main content

Quickstart: Training

Train your first machine-learning model in under five minutes, then serve it through the same inference path as any catalog model.


Prerequisites

  • A ColabHive account (console.colabhive.com)
  • Python 3.8+
  • A dataset in CSV format (or use one of the examples below)

Step 1 — Install the SDK

pip install colabhive

Step 2 — Get your API key and account ID

  1. Log in to console.colabhive.com
  2. Go to Settings → API Keys
  3. Click Create New API Key
  4. Copy your API key (starts with hive_) and your Account ID
export COLABHIVE_API_KEY="hive_..."
export COLABHIVE_ACCOUNT_ID="..."

Step 3 — Upload your dataset

import os
from colabhive import ColabHive

client = ColabHive(
api_key=os.getenv("COLABHIVE_API_KEY"),
account_id=os.getenv("COLABHIVE_ACCOUNT_ID"),
)

dataset = client.datasets.upload(
name="my_first_dataset",
file="./data.csv",
)

print(f"Dataset uploaded: {dataset.id}")
print(f" Name: {dataset.dataset_name}")
print(f" Size: {dataset.size_mb:.2f} MB")
print(f" Format: {dataset.format}")

Supported dataset formats are csv, jsonl, parquet, and hf_dataset.

Don't have a dataset?

Download an example:


Step 4 — Train a model

job = client.training.create(
model="xgboost-regression",
dataset_id=dataset.id,
job_name="My First Model",
)

print(f"Training started: {job.id}")
print(f" Status: {job.status}")

xgboost-regression is one of many trainable templates. Browse trainable models with client.training.model_configs() or GET /api/builder/v1/training/model-configs, and see Choosing a Model for how to pick one.


Step 5 — Monitor progress

job.wait(poll_interval=5, verbose=True)

if job.status == "completed":
print("Training complete.")
for metric in (job.metrics or []):
print(f" {metric}")
else:
print(f"Training failed: {job.error_message}")

Step 6 — Use your model

models = client.models.list()
print(f"You have {len(models)} trained models")

if models:
model_file = client.models.download(
models[0].id,
output_path="./my_model.pkl",
)
print(f"Model downloaded to: {model_file}")

To serve a trained model through the inference API, register it — see Register a Trained Model for Inference.


Next steps