No project description provided
Project description
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 |
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
serialzy-1.5.1.tar.gz
(18.8 kB
view details)
Built Distribution
serialzy-1.5.1-py3-none-any.whl
(27.9 kB
view details)
File details
Details for the file serialzy-1.5.1.tar.gz
.
File metadata
- Download URL: serialzy-1.5.1.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1052a0f6116dcde238888f47a34d9f20292fe8c274d2a7da0dea2e338665a2e |
|
MD5 | c8ad88c12211b8c644049d09f40e8a20 |
|
BLAKE2b-256 | 06dfb945233eb7cc640a452d05d5a98ede2d54efc8e4c8549f9d1fcc2eaf346e |
File details
Details for the file serialzy-1.5.1-py3-none-any.whl
.
File metadata
- Download URL: serialzy-1.5.1-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5313ce545dd4850d8c32b2c057e5b383c5032a00c8b8b9c908212c2a6aedac3c |
|
MD5 | 286efe6339af487ba69be6cd0dd49ff5 |
|
BLAKE2b-256 | ac87a5d66604a106051d1e2c79b291340c9c457bd639a3bcc14ce840090fc3ac |