Skip to main content

Modelzone SDK – a slim model training and serving toolkit

Project description

Modelzone SDK

A slim Python SDK for defining, training, and serving machine-learning models.

Installation

pip install modelzone-sdk

For local training with Delta Lake data access:

pip install modelzone-sdk[training]

For AzureML experiment tracking:

pip install modelzone-sdk[azureml]

Quick start

Define a model by subclassing ModelDefinition and implementing train and predict:

from modelzone.core import ModelDefinition, PredictContext, ModelArtifact
from modelzone.training import TrainingContext


class MyModel(ModelDefinition):
    def train(self, ctx: TrainingContext) -> ModelArtifact:
        ctx.print("Training started")

        # … your training logic …
        fitted = train_something(seed=ctx.seed)

        ctx.log_metric("accuracy", 0.95)
        return ModelArtifact(model=fitted, features=["feature_a", "feature_b"])

    def predict(self, ctx: PredictContext):
        df = ctx.db.query("input_table", ctx.time_interval)
        return ctx.model.predict(df[ctx.features])

Local training

from modelzone.training import LocalBackend

backend = LocalBackend(root="./runs")
result = backend.run(MyModel(), seed=42, params={"lr": 0.01})
print(result.run_id)

AzureML training

from modelzone.azureml import AzureMLBackend

backend = AzureMLBackend(
    subscription_id="...",
    resource_group="...",
    workspace_name="...",
    experiment_name="my_experiment",
)
result = backend.run(MyModel(), seed=42)

Loading a trained model for prediction

from modelzone.predict import load_model_artifact

model_artifact = load_model_artifact(".model")
print(model_artifact.features)

CLI

modelzone train my_model_package            # Local training
modelzone train my_model_package --azureml   # AzureML training
modelzone register my_model_package <run_id>
modelzone fetch my_model_package --output-dir .model

Development

poetry install --with dev,test
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelzone_sdk-0.3.1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelzone_sdk-0.3.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file modelzone_sdk-0.3.1.tar.gz.

File metadata

  • Download URL: modelzone_sdk-0.3.1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.17.0-1008-azure

File hashes

Hashes for modelzone_sdk-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e585da03a753f8de0138528151710f30bb1d804928b121a9ada2e026deb10d95
MD5 d92017bb60ede95034ac66a4a67d0cf3
BLAKE2b-256 f5df2ba29d90ed09c3b76901eb855e98f2e555853602f528154c3e064256780b

See more details on using hashes here.

File details

Details for the file modelzone_sdk-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: modelzone_sdk-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.17.0-1008-azure

File hashes

Hashes for modelzone_sdk-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b9f0d30249dac97d9265524e3fca49519b07b676627b70ef1be3cbf4d5841db
MD5 57739b9a2819506c2d310deb789fa12a
BLAKE2b-256 86cb34c32f0a9ceade2da2f7f1c1488dfb10518578d8224ce80696322677ddce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page