PickleIOMixin#
- class scikitplot.annoy.PickleIOMixin[source]#
Mixin adding explicit Python-object to pickling dump/load helpers.
Notes
This mixin serializes the Python object using a pickle-family backend. It should not be used as a substitute for Annoy’s native index persistence. Prefer composing with
PickleMixinif you need Annoy-aware, deterministic object serialization.- dump_pickle(path, *, backend='joblib', **kwargs)[source]#
Serialize this object to a binary file.
- Parameters:
- pathstr or os.PathLike
Destination path.
- backend{‘pickle’, ‘cloudpickle’, ‘joblib’}, default=’joblib’
Backend used for serialization.
- **kwargs
Extra keyword arguments forwarded to the backend dumper.
joblib: forwarded tojoblib.dump(e.g.compress=3)pickle: currently unused (kept for forwards compatibility)cloudpickle: currently unused (kept for forwards compatibility)pickle/cloudpickle: acceptsprotocol=intto control the pickle protocol.
- Raises:
- ValueError
If
backendis unsupported.- OSError
If the file cannot be written.
- Parameters:
- Return type:
None
- classmethod load_pickle(path, *, backend='joblib', **kwargs)[source]#
Load an object from a binary file.
- Parameters:
- pathstr or os.PathLike
File path to read.
- backend{‘pickle’, ‘cloudpickle’, ‘joblib’}, default=’joblib’
Backend used for deserialization.
- **kwargs
Extra keyword arguments forwarded to the backend loader.
joblib: forwarded tojoblib.loadpickle: currently unused (kept for forwards compatibility)cloudpickle: currently unused (kept for forwards compatibility)
- Returns:
- objSelf
Deserialized object. Ensures the returned instance is of type
cls.
- Raises:
- ValueError
If
backendis unsupported.- TypeError
If the deserialized object is not an instance of
cls.- FileNotFoundError
If the file does not exist.
- Parameters:
- Return type:
Notes
All supported backends can execute arbitrary code during loading. Do not load untrusted data.