Modelzone SDK – a slim model training and serving toolkit
Project description
ModelZone SDK
A Python package for managing, training, and installing machine learning models. The package consists of:
- A Python SDK used for writing the code for training and inference of a machine learning model.
- A CLI used for tracking and registration of models in Azure ML.
Installation
pip install modelzone-sdk
Overview
Taking a look at the various Python machine learning frameworks out there, you will come across many different workflows used for training and prediction. ModelZone SDK uses the following definition:
A model project is a Python package with a training function, which is responsible for (1) tracking metrics and graphs used for comparing different model experiments and (2) generating model artifacts (such as model parameters and hyper-parameters) that need to be shipped with the package.
ModelZone SDK assumes your machine learning workflow looks more or less like the following:
- Experimentation by training different models (and hyper-parameters).
- Release of the best suited model for production usage.
- Using the released model for inference in operations.
Quick guide
We have made an example of how a training and inference project should look like:
- Training project: examples/training_example
- Inference project: examples/predict_example
- Test script running the full workflow: examples/test.sh
Detailed guide
Model project structure
Training function
Your training function must be defined within the Python package:
# my-model/model.py
def train():
X, y = ...
lin_reg = LinearRegression()
lin_reg.fit(X, y)
Tracking
If you have experience with the built-in logging module of Python, tracking experiment data with ModelZone SDK will feel much the same. Tracking is done using a global tracker, which needs to be configured before running your code (when using the CLI tool, this takes care of configuring your tracker to log to the correct place; local or Azure AI Workspace).
Metrics and visualziation
The tracker can be used for logging metrics and visualizations for your experiment run:
# my-model/model.py
import modelzone as mz
tracker = mz.get_tracker()
def train():
X, y = ...
lin_reg = LinearRegression()
tracker.log_tag("model_type", "LinearRegression")
lin_reg.fit(X, y)
y_hat = lin_reg.predict(X)
mae = (y - y_hat).abs().mean()
tracker.log_metric("MAE", mae)
The tracker can also be used for logging artifacts for your experiment run (e.g. model parameters). You define an artifact by inheriting from the Artifact class available in ModelZone SDK (all this does is to provide methods for saving and loading the class using the pickle module):
# my-model/model.py
import modelzone as mz
tracker = mz.get_tracker()
class Predictor(mz.Artifact):
def __init__(self, model: Estimator):
self.model = model
def predict(self, ...):
...
def train():
X, y = ...
lin_reg = LinearRegression()
lin_reg.fit(X, y)
predictor = Predictor(lin_reg)
tracker.log_artifact("my-artifact", predictor)
When installing this package elsewhere, you can now get back the artifact as follows:
from mypackage import Predictor
predictor = Predictor.load(name="my-artifact")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelzone_sdk-2.0.1.tar.gz.
File metadata
- Download URL: modelzone_sdk-2.0.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/6.17.0-1011-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b8c4fed5deaaed84c31263258511a974e6c8b87b75a7071c59d5cfdc6759e8a
|
|
| MD5 |
8492b7f362727e557d084929f7a85432
|
|
| BLAKE2b-256 |
824d92835a8c2dc34fa4b402ea0650f715ed967818655939f8211ec797f5ab3d
|
File details
Details for the file modelzone_sdk-2.0.1-py3-none-any.whl.
File metadata
- Download URL: modelzone_sdk-2.0.1-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/6.17.0-1011-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d56c2b5e0541cb5719f2ccc3d577e947ca83373758891f5313f7ed711bfd0956
|
|
| MD5 |
ef25216702928dc56ffa3fa4321661de
|
|
| BLAKE2b-256 |
96159c55c9e94302485f6fa23b7690a0b44f05b3e1108489ec18f161469b2907
|