acies.vehicle_classifier.base#
Functions
|
Perform ensemble voting on the buffered predictions. |
|
Convert between physical and digital twin topic. |
|
Perform soft voting on a list of predictions. |
|
Decorator to log the time difference between consecutive calls to a function. |
Classes
A template classifier for vehicle data. |
- class acies.vehicle_classifier.base.Classifier#
Bases:
ServiceA template classifier for vehicle data. This class should be subclassed and the load_model and infer methods implemented.
- __init__(classifier_config_file, twin_model, twin_buff_len, sync_interval, feature_twin, *args, **kwargs)#
Initialize the Classifier.
- Parameters:
classifier_config_file (str) – Path to the classifier configuration file.
twin_model (str) – The digital twin model to use.
twin_buff_len (int) – The buffer length for the digital twin.
sync_interval (int) – The synchronization interval for the digital twin.
feature_twin (bool) – Whether to use the digital twin features.
- combine_meta(meta_data)#
Combine metadata from two topics.
- get_keys_per_node(modalities)#
Get the keys for each node based on the modalities.
- handle_message()#
Handle incoming messages from the message queue.
- infer(samples)#
Perform inference on incoming samples.
This method must be implemented by concrete classifiers. The scheduler periodically invokes it with new data.
- Parameters:
samples (dict[str, dict[int, numpy.ndarray]]) –
Nested mapping of time-series data.
Keys (
str): Topic name, such asrs1/micorrs1/geo.- Values (
dict): Data received from that topic. Keys (
int): Unix timestamp in seoncds.Values (
numpy.ndarray): One-dimensional arrays containing the raw samples recorded during that second.
- Values (
Example
samples = { "rs1-1/geo": { 1757515699: array([16961, 16907, ..., 16551, 16370]), 1757515700: array([16217, 16418, ..., 16913, 16799]), }, "rs-1/mic": { 1757515699: array([-62, -51, -63, ..., 182, 207, 178]), 1757515700: array([194, 210, 174, ..., 233, 247, 210]), }, }
- Returns:
Inference results produced by the classifier.
- Return type:
Any
- Raises:
NotImplementedError – If the subclass does not override this method.
- load_model(*args, **kwargs)#
Load model from give path.
- log_activate_status()#
Log the activation status.
- run()#
Run the main loop.
- temp_ensmeble(node, msg)#
Perform temporal ensemble on the classification results.
- Parameters:
node (str) – The node name.
msg (Message) – The message containing the classification results.
- Raises:
ValueError – If the ensemble buffer is not sufficient.
- acies.vehicle_classifier.base.ensemble(buff, win, size, conf_thresh)#
Perform ensemble voting on the buffered predictions.
- Parameters:
- Raises:
ValueError – If there are not enough predictions for ensembling.
- Returns:
The ensemble prediction and metadata.
- Return type:
- acies.vehicle_classifier.base.get_twin_topic(topic)#
Convert between physical and digital twin topic.
- acies.vehicle_classifier.base.soft_vote(pred_list)#
Perform soft voting on a list of predictions.
- acies.vehicle_classifier.base.time_diff_decorator(func)#
Decorator to log the time difference between consecutive calls to a function.
- Parameters:
func (Callable) – The function to decorate.
- Returns:
The decorated function.
- Return type:
Callable