algorithm
logger = logging.getLogger(__name__) module-attribute ¶
ALGORITHM_REGISTRY = AlgorithmRegistry() module-attribute ¶
Registry instantiation for algorithms.
Contains the streamsight algorithms by default and allows registration of new algorithms via the register function.
Examples:
from streamsight.pipelines import ALGORITHM_REGISTRY
# Construct an ItemKNN object with parameter K=20
algo = ALGORITHM_REGISTRY.get("ItemKNN")(K=20)
from streamsight.algorithms import ItemKNN
ALGORITHM_REGISTRY.register("HelloWorld", ItemKNN)
# Also construct an ItemKNN object with parameter K=20
algo = ALGORITHM_REGISTRY.get("HelloWorld")(K=20)
AlgorithmRegistry ¶
Registry for easy retrieval of algorithm types by name.
The registry is pre-registered with all streamsight algorithms.
Source code in src/streamsight/registries/algorithm.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
IS_BASE = True class-attribute instance-attribute ¶
name property ¶
Name of the object's class.
:return: Name of the object's class :rtype: str
registered = {} instance-attribute ¶
src = src instance-attribute ¶
get(key) ¶
Retrieve the value for this key.
This value is a Python type, most often a class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | str | The key to fetch. | required |
Returns:
| Type | Description |
|---|---|
T | The class type associated with the key. |
Raises:
| Type | Description |
|---|---|
KeyError | If the key is not found in the registry. |
Source code in src/streamsight/registries/base.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
register(key, cls) ¶
Register a new Python type (most often a class).
After registration, the key can be used to fetch the Python type from the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | str | Key to register the type at. Needs to be unique to the registry. | required |
cls | T | Class to register. | required |
Raises:
| Type | Description |
|---|---|
KeyError | If the key is already registered. |
Source code in src/streamsight/registries/base.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
get_registered_keys(include_base=False) ¶
Get a list of all registered keys.
Returns:
| Type | Description |
|---|---|
list[str] | A list of all registered keys. |
Source code in src/streamsight/registries/base.py
106 107 108 109 110 111 112 113 114 115 | |
registered_values() ¶
Get a list of all registered types.
Returns:
| Type | Description |
|---|---|
list[T] | A list of all registered types. |
Source code in src/streamsight/registries/base.py
117 118 119 120 121 122 123 | |
registered_items() ¶
Get a list of all registered key-type pairs.
Returns:
| Type | Description |
|---|---|
list[tuple[str, T]] | A list of all registered key-type pairs. |
Source code in src/streamsight/registries/base.py
125 126 127 128 129 130 131 | |
AlgorithmEntry ¶
Bases: NamedTuple
Entry for the algorithm registry.
The intended use of this class is to store the name of the algorithm and the parameters that the algorithm should take. Mainly this is used during the building phase of the evaluator pipeline in Builder.
Attributes:
| Name | Type | Description |
|---|---|---|
name | str | Name of the algorithm. |
params | None | dict[str, Any] | Parameters that do not require optimization as key-value pairs, where the key is the hyperparameter name and the value is the value it should take. |
Source code in src/streamsight/registries/algorithm.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |