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 |
Metadata
Release files for serialzy 1.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| serialzy-1.5.2.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| serialzy-1.5.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.1 kB
Release files / serialzy-1.5.2.tar.gz
| Download URL | serialzy-1.5.2.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f927b238f0765d95124f2ba526cdb6fcb3ec9c5cff93ccdd29b3ec229857df6
|
|
BLAKE2b-256 checksum How to use checksums |
ca1aaeee7b3da43d309c3beb7534a7f74d2af09539709110e5229058a80797ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Release files / serialzy-1.5.2-py3-none-any.whl
| Download URL | serialzy-1.5.2-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c89bfbbeeb7b71dbdbafd94d3ae6b8318e19d3dacc1b9f250e8946c8af28f4a5
|
|
BLAKE2b-256 checksum How to use checksums |
20eef33a6406916fa7b8b4a202045790d476226b5dcb73941edd8c7c9e72fb6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|