Make life easier for saving and serving ML models
Project description
mlModelSaver documentation
Introducing mlModelSaver – a streamlined Python module designed for data scientists and developers who seek a straightforward solution for model saving and serving.
While numerous tools are available for training machine learning models, many lightweight statistical models lack simple, efficient saving mechanisms. Existing enterprise solutions like MLflow are robust but come with considerable complexity. Based on my experience, I saw the need for an abstract model registry concept that simplifies this process.
mlModelSaver fills this gap, offering an intuitive way to save machine learning models and transformers. It facilitates seamless integration with frameworks like FastAPI (Examples), Flask, and Django, enabling easy deployment and serving of models in production environments. Empower your machine learning workflow with mlModelSaver – the easy and efficient tool for model management.
Installation
You can install mlModelSaver via pip:
pip install mlModelSaver
mlModelSaver Example: Simple Linear Regression
In this example, we demonstrate how to use mlModelSaver to export a simple linear regression model based on a notebook from ml_models_deployments.
Example Description
This example builds a simple linear regression model to predict sales based on temperature, advertising, and discount factors. Once the model is fitted and satisfactory, mlModelSaver allows you to easily save and deploy the model for use in production environments.
Example Code - notebook available here
def add_constant_columnTransformer(df):
# example transformer
df_with_const = df.copy()
df_with_const.insert(0, 'const', 1)
return df_with_const
# Export the model using MlModelSaver
loadedModel = mlModelSaverInstance.exportModel(
simpleLinearRegressionFittedModel, # the models is fitted and ready for usage
{
"modelName": "modelPredictSaleByTemperatureAdvertisingDiscountFit",
"description": "Example model predicting sales based on temperature, advertising, and discount.",
"modelType": "sm.OLS", # Example model type (replace with actual type)
"inputs": [
{"name": "Temperature", "type": "float"},
{"name": "Advertising", "type": "float"},
{"name": "Discount", "type": "float"}
],
"transformer": add_constant_columnTransformer, # Use your transformation function here
"outputs": [
{
"name": "Sales",
"type": "float"
}
]
}
)
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
Hashes for mlModelSaver-1.0.22-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4978cdde7842d4625e414f1a1f75e1da2b22a71b79acddc4fc843b7eb35cdc43 |
|
MD5 | 02d83b2ced7a08e99e6137142b5b4226 |
|
BLAKE2b-256 | e035dd412e78cb95c929c40d3e472955e325bf7dea83cbfdd044914c4c8eb76c |