Skip to main content

Transportation of ML models

Project description


Table of contents

Overview

Pymilo is an open source Python package that provides a simple, efficient, and safe way for users to export pre-trained machine learning models in a transparent way. By this, the exported model can be used in other environments, transferred across different platforms, and shared with others. Pymilo allows the users to export the models that are trained using popular Python libraries like scikit-learn, and then use them in deployment environments, or share them without exposing the underlying code or dependencies. The transparency of the exported models ensures reliability and safety for the end users, as it eliminates the risks of binary or pickle formats.

PyPI Counter
Github Stars
Branch main dev
CI

Installation

PyPI

Source code

Usage

Simple Linear Model Preparation

>>> from sklearn import datasets
>>> from pymilo import Export, Import
>>> from sklearn.linear_model import LinearRegression
>>> import os
>>> X, Y = datasets.load_diabetes(return_X_y=True)
>>> threshold = 20
>>> X_train, X_test = X[:-threshold], X[-threshold:]
>>> Y_train, Y_test = Y[:-threshold], Y[-threshold:]
>>> model = LinearRegression()
>>> #### Train the model using the training sets
>>> model.fit(X_train, Y_train)

Save Model

>>> #### Export the fitted model to a transparent json file
>>> exported_model = Export(model)
>>> PATH_TO_JSON_FILE = os.path.join(os.getcwd(),"test.json")
>>> exported_model.save(PATH_TO_JSON_FILE)

Load Model

>>> #### Import the pymilo-exported model and get a real scikit model
>>> imported_model = Import(PATH_TO_JSON_FILE)

Get the associated Scikit model

>>> imported_sklearn_model = imported_model.to_model()

Note: imported_sklearn_model has the exact same functionality as the model object earlier.

Supported ML Models

scikit-learn PyTorch
Linear Models ✅ -
Neural networks ✅ -
Clustering ❌ -
Trees ❌ -
Ensemble Models ❌ -
Details are available in Supported Models.

Issues & bug reports

Just fill an issue and describe it. We'll check it ASAP! or send an email to info@openscilab.com.

  • Please complete the issue template

You can also join our discord server

Discord Channel

Show Your Support

Star this repo

Give a ⭐️ if this project helped you!

Donate to our project

If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .

PyMilo Donation

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

0.2 - 2023-08-02

Added

  • scikit-learn neural network models
  • MLP Regressor model
  • MLP Classifier model
  • BernoulliRBN model
  • SGDOptimizer transporter
  • RandomState(MT19937) transporter
  • Adamoptimizer transporter
  • Neural Network chain
  • Neural Network exceptions
  • ndarray_to_list method in GeneralDataStructureTransporter
  • list_to_ndarray method in GeneralDataStructureTransporter
  • neural_network_chain.py chain

Changed

  • GeneralDataStructure Transporter updated
  • LabelBinerizer Transporter updated
  • linear model chain updated
  • GeneralDataStructure transporter enhanced
  • LabelBinerizer transporter updated
  • transporters' chain router added to pymilo func
  • NeuralNetwork params initialized in pymilo_param
  • pymilo_test updated to support multiple models
  • linear_model_chain refactored

0.1 - 2023-06-29

Added

  • scikit-learn linear models support
  • Export class
  • Import class

Download files

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

Source Distribution

pymilo-0.2.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

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

pymilo-0.2-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file pymilo-0.2.tar.gz.

File metadata

  • Download URL: pymilo-0.2.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pymilo-0.2.tar.gz
Algorithm Hash digest
SHA256 8f8e00952b75d27b7b71c13168e1dac7b5a088ac1cdf56a27c58a82751f90656
MD5 0c06084b36ee9c4744a3c44fb39f2275
BLAKE2b-256 73620bf06a1987600e4a079e6b57fe50f61f7997ebaffde41a46bceb0d5eb4be

See more details on using hashes here.

File details

Details for the file pymilo-0.2-py3-none-any.whl.

File metadata

  • Download URL: pymilo-0.2-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pymilo-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc16dca74c59d6f4688347ae63b77a0da93e8f1672a1c43f42b4914af989bab4
MD5 ff24cb61e8f56c04aba9ce720899cff4
BLAKE2b-256 2dd0d54135a026e4731588f8d642d4ae76684c9c6c9f7e44506a56923c4d346b

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