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.1a0.tar.gz (16.1 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.1a0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelzone_sdk-0.3.1a0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.0 CPython/3.13.13 Linux/6.17.0-1010-azure

File hashes

Hashes for modelzone_sdk-0.3.1a0.tar.gz
Algorithm Hash digest
SHA256 61775f1bfb66a3aeb82dbc84a3c38d98e0f4258e8d0c2081261f8a538c9dc954
MD5 3355005e5f1a07b7f1a0a1f9f6e1ed2e
BLAKE2b-256 03cfe7c9c9879db64411e8d74e55ccf5f867c8ea296b2498022d84d71d197f6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modelzone_sdk-0.3.1a0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.0 CPython/3.13.13 Linux/6.17.0-1010-azure

File hashes

Hashes for modelzone_sdk-0.3.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b939c347043117ff28ffdeac74332445ab4f070f8d8b960e63fe55fd886401f
MD5 24bb244cf7e501666c4fd1d77ce5d160
BLAKE2b-256 d39faaa611d032f8cdae14ac65afd3e7934990c06d2064bc8e8fb4031bedfa20

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