EasyTSAD.TSADController
TSADController
TSADController(cfg_path=None, log_path=None, log_level='info')
TSADController class represents a controller that manages global configuration and logging.
Attributes:
Name | Type | Description |
---|---|---|
summary |
Summary
|
summary the trained results, including generating CSV and aggregating all methods' anomaly scores on specific curve in one plot. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cfg_path |
str
|
Path to the configuration file. If provided, the configuration will be applied from this file. Defaults to None (Not Recommanded). |
None
|
log_path |
str
|
Path to the log file. If not provided, a default log file named "TSADEval.log" will be built in current workspace. Defaults to None. |
None
|
log_level |
str
|
Log level to set for the logger. Options: "debug", "info", "warning", "error". Defaults to "info". |
'info'
|
apply_cfg
apply_cfg(path=None)
Applies configuration from a file.
This method reads a configuration file from the specified path and overrides the corresponding default values.
NOTE
If no path is provided, it uses a default configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the configuration file. If None, default configuration is used. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
None |
do_evals
do_evals(method, training_schema)
Performing evaluations based on saved anomaly scores. The result will be saved in Results/Evals, including the detailed evaluation results and the average evaluation results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
The method being used. |
required |
training_schema |
str
|
The training schema being used. |
required |
plots
plots(method, training_schema)
Generate plots for the specified method and training schema. The plots are located in Results/Plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
Method name. |
required |
training_schema |
str
|
Training schema name. |
required |
Returns:
Type | Description |
---|---|
None |
run_exps
run_exps(method, training_schema, cfg_path=None, diff_order=None, preprocess=None, hparams=None)
Run experiments using the specified method and training schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
The method being used. |
required |
training_schema |
str
|
The training schema being used. One of one_by_one, all_in_one, zero_shot, zero_shot_cross_ds. |
required |
cfg_path |
str
|
Path to a custom configuration file. Defaults to None. |
None
|
diff_order |
int
|
The differential order. Defaults to None. |
None
|
preprocess |
str
|
The preprocessing method. Options: "raw", "min-max", "z-score". Defaults to None (equals to "raw"). |
None
|
hparams |
dict
|
Hyperparameters for the model. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
None |
Raises:
Type | Description |
---|---|
ValueError
|
If the specified training schema is not one of "one_by_one", "all_in_one", or "zero_shot". |
set_dataset
set_dataset(datasets, dirname=None, dataset_type='UTS', specify_curves=False, curve_names=None, train_proportion=None, valid_proportion=None)
Registers the dataset settings and related parameters for the TSADController instance. This will check if the paths and the parameters are valid.
NOTE
If you want to run all curves in the dataset, set "specify_curves" to False. In this mode, "curve_names" should be set to None.
Otherwise, if you want to specify some time series in a dataset, please specify ONLY ONE dataset and the curves in this dataset. E.g. set_dataset(datasets="WSD", "curve_names"=["1", "2"])
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datasets |
Union[str, list[str]]
|
Name(s) of the dataset(s) to be set. Can be a single string or a list of strings. |
required |
dirname |
str
|
Path to the dataset directory. If not provided, it will be fetched from the configuration file. Defaults to None. |
None
|
curve_type |
str
|
Type of the datasets. Defaults to "UTS". |
required |
specify_curves |
bool
|
Flag indicating whether to specify individual curves within the dataset(s). Defaults to False. |
False
|
curve_names |
Union[None, str, list[str]]
|
Name(s) of the curve(s) to be used. Can be None, a single string, or a list of strings. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset directory path is not specified. |
FileNotFoundError
|
If the dataset directory or any of the specified datasets or curves do not exist. |
Returns:
Type | Description |
---|---|
None |
set_evals
set_evals(evals)
Registers the evaluation protocols used for performance evaluations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
evals |
list[EvalInterface]
|
The evaluation instances inherited from EvalInterface. |
required |