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.2.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.2-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelzone_sdk-0.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 89ec67305727f79a6310dd757c3c88ab318cc2d2acd47b785886b3a1f61b7724
MD5 6f36b5ca885f2540948bdadcfd90a98f
BLAKE2b-256 0d0e6ef1ddffd3b6d82648ddb948b128793225c9c192bbed00b425df3e0a3a59

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modelzone_sdk-0.3.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c67a4b5cc707daf403d81ceb86a36c3576e4b8ac2b5e3fd3b5c4a976b0814ca9
MD5 5217c77c5f075d3aafc37ec573791cd0
BLAKE2b-256 cfc257dce5d055dd7a1cf4dcd27861e2f1e04974e54e1657ba3b97c0d813f78b

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