chariots.serializers¶
Serializers are utils classes that are used throughout the Chariots framework to transform objects into bytes. there are for instance used to serialize the inner models of the machine learning ops:
>>> class LinearRegression(SKSupervisedOp):
...
... serializer_cls = MySerializerCls
...
... model_class = PCA
there are also usually used in the saving nodes to choose the serialization method for your datasets:
>>> saving_node = DataSavingNode(serializer=CSVSerializer(), path='my_path.csv', input_nodes=["my_dataset"])
-
class
chariots.serializers.
DillSerializer
[source]¶ Bases:
chariots.base._base_serializer.BaseSerializer
serializes objects using the dill library (similar to pickle but optimized for numpy arrays.
-
class
chariots.serializers.
JSONSerializer
[source]¶ Bases:
chariots.base._base_serializer.BaseSerializer
serializes objects into JSON format
-
class
chariots.serializers.
CSVSerializer
[source]¶ Bases:
chariots.base._base_serializer.BaseSerializer
A serializer to save a pandas data frame.
- Raises
Typeerror – if the node receives something other than a pandas DataFrame
-
deserialize_object
(serialized_object: bytes) → pandas.core.frame.DataFrame[source]¶ returns the deserialized object from serialized bytes (that will be loaded from a saver)
- Parameters
serialized_object – the serialized bytes
- Returns
the deserialized objects
-
serialize_object
(target: pandas.core.frame.DataFrame) → bytes[source]¶ serializes the object into bytes (for ml ops target will be the model itself and not the op, for the data ops the target will be the input of the node )
- Parameters
target – the object that will be serialized
- Returns
the bytes of the serialized object