Skip to main content

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

XGBoost

PyTorch

Keras

License

Apache License 2.0

Project details


Download files

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

Source Distribution

clearbox-wrapper-0.2.1.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

clearbox_wrapper-0.2.1-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page