Skip to content

openscilab/pymilo

Repository files navigation



Codecov PyPI version built with Python3 Discord Channel

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
Code Quality CodeFactor codebeat badge

Installation

PyPI

Source code

Usage

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 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 ✅ -
Trees ✅ -
Clustering ✅ -
Naïve Bayes ✅ -
Support vector machines (SVMs) ✅ -
Nearest Neighbors ✅ -
Ensemble Models ✅ -
Pipeline Model ✅ -
Preprocessing 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 [email protected].

  • 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