An agnostic wrapper for the most common frameworks of ML models.
Project description
Clearbox Wrapper
Clearbox Wrapper is an agnostic wrapper for the most used machine learning frameworks, with the aim to facilitate the transfer of models between different cloud environments and to provide a common interface for generating output predictions.
Usage
With a few lines of code it is possible to create a wrapper for your model, simply specifying how to perform a prediction and how to carry out input preprocessing operations if necessary.
For example, if you have just trained a model using Sklearn and your input doesn't need preprocessing, just define a class that inherits from SklearnWrapper and specify how to perform the predict method. After that, it will be sufficient to use the Sklearn wrapper dump method to have your model serialized on the disk.
from sklearn.linear_model import LinearRegression
...
lr = lr = LinearRegression()
lr.fit(X_train, y_train)
...
from clearbox_wrapper.SklearnWrapper import SklearnWrapper
class MyModel(SklearnWrapper):
def predict(self, X):
return self.model.predict(X)
MyModel(lr).dump('sklearn_boston.model')
At this point you can move the newly created file to any environment you want and simply deserialize it to be able to use it.
from clearbox_wrapper.SklearnWrapper import SklearnWrapper
foo = SklearnWrapper.load('sklearn_boston.model')
foo.predict(data)
Examples
Sklearn
- Boston Housing Dataset - Notebook
XGBoost
- Pima Indians Diabetes - Notebook
PyTorch
- CIFAR-10 - Notebook
Keras
- Fashion MNIST - Notebook
License
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 clearbox_wrapper-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 404aceecf9dc3847db276746b3e6f062eb837e6cb96e522441d3d1c67cd299f7 |
|
MD5 | 2d5ae5be11e2af0347a2f604e13356ab |
|
BLAKE2b-256 | 2a2143f4f49774fc1a21ec40f071a4d29f1771bd2973a7704f7bc437b46dc0b1 |