Giter Club home page Giter Club logo

serialzy's Introduction

Pypi version Tests Python tests coverage PyPI - Python Version

serialzy

Serialzy is a library for python objects serialization into portable and interoperable data formats (if possible).

Example

Suppose you have a catboost model:

from catboost import CatBoostClassifier

model = CatBoostClassifier()
model.fit(...)

Firstly you should find a proper serializer for the catboost model type or the corresponding data format:

from serialzy.registry import DefaultSerializerRegistry

registry = DefaultSerializerRegistry()
serializer = registry.find_serializer_by_type(type(model)) # registry.find_serializer_by_data_format("cbm")

Serializers have several properties:

serializer.available()      # can be used in the current environment
serializer.requirements()   # libraries needed to be installed to use this serializer
serializer.stable()         # has portable data format

Serializers can provide data format and schema for a type:

serializer.data_format()
serializer.schema(type(model))

Serialization:

with open('model.cbm', 'wb') as file:
    serializer.serialize(model, file)

Deserialization:

with open('result', 'rb') as file:
    deserialized_obj = serializer.deserialize(file)

List of supported libraries for stable serialization:

Library Types Data format
Python std lib int, str, float, bool, None string representation
Python std lib List, Tuple custom format
CatBoost CatBoostRegressor, CatBoostClassifier, CatBoostRanker cbm
CatBoost Pool quantized pool
Tensorflow.Keras Sequential, Model with subclasses tf_keras
Tensorflow Checkpoint, Module with subclasses tf_pure
LightGBM LGBMClassifier, LGBMRegressor, LGBMRanker lgbm
XGBoost XGBClassifier, XGBRegressor, XGBRanker xgb
Torch Module with subclasses pt
ONNX ModelProto onnx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.