Serialization¶
All model classes support save(filepath) / cls.load(filepath) round-trips.
See the README for usage examples.
SerializationError¶
online_cp._serialization.SerializationError
¶
register_callable¶
online_cp._serialization.register_callable(name: str) -> Callable
¶
Register a callable under name for serialization.
Use this decorator on module-level functions or classes that you want to
pass as kernel, distance_func, or similar arguments to a model and
then be able to save/load that model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique registry key. Must be the same in the saving and loading process. |
required |
Examples:
>>> @register_callable("my_distance")
... def my_distance(X, y=None):
... import numpy as np
... from scipy.spatial.distance import cdist, pdist, squareform
... if y is None:
... return squareform(pdist(X))
... return cdist(X, y)