canari.skf_optimizer#
This module automates the search for optimal hyperparameters of a
SKF
instance by leveraging the Ray Tune
external library.
- class canari.skf_optimizer.SKFOptimizer(initialize_skf: Callable, model_param: dict, param_space: dict, data: dict, detection_threshold: float | None = 0.5, false_rate_threshold: float | None = 0.0, max_timestep_to_detect: int | None = None, num_synthetic_anomaly: int | None = 50, num_optimization_trial: int | None = 50, grid_search: bool | None = False, algorithm: str | None = 'default')[source]#
Bases:
object
Optimize hyperparameters for
SKF
using the Ray Tune external library.- Parameters:
initialize_skf (Callable) – Function that returns an SKF instance given a configuration.
model_param (dict) – Serializable dictionary for
Model
obtained fromget_dict()
.param_space (dict) – Parameter search space: two-value lists [min, max] for defining the bounds of the optimization.
data (dict) – Input data for adding synthetic anomalies.
detection_threshold (float, optional) – Threshold for the target maximal anomaly detection rate. Defaults to 0.5.
false_rate_threshold (float, optional) – Threshold for the maximal false detection rate. Defaults to 0.0.
max_timestep_to_detect (int, optional) – Maximum number of timesteps to allow detection. Defaults to None (to the end of time series).
num_synthetic_anomaly (int, optional) – Number of synthetic anomalies to add. This will create as many time series, because one time series contains only one anomaly. Defaults to 50.
num_optimization_trial (int, optional) – Number of trials for optimizer. Defaults to 50.
grid_search (bool, optional) – If True, perform grid search. Defaults to False.
algorithm (str, optional) – Search algorithm: ‘default’ (OptunaSearch) or ‘parallel’ (ASHAScheduler).
'OptunaSearch'. (Defaults to)
- skf_optim#
Best SKF instance after optimization.
- param_optim#
Best hyperparameter configuration.
- Type:
dict
- detection_threshold#
Threshold for detection rate for anomaly detection.
- false_rate_threshold#
Threshold for false rate.
- get_best_model()[source]#
Retrieves the SKF instance initialized with the best parameters.
- Returns:
SKF instance corresponding to the optimal configuration.
- Return type:
Any