RADAR.time_series.algorithms
Subpackages
- RADAR.time_series.algorithms.modelsTransformersTS
- Subpackages
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer
- Submodules
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer.attn module
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer.decoder module
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer.embed module
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer.encoder module
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer.endec module
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer.model module
- Module contents
- RADAR.time_series.algorithms.modelsTransformersTS.informer
- Submodules
- RADAR.time_series.algorithms.modelsTransformersTS.informer.attn module
- RADAR.time_series.algorithms.modelsTransformersTS.informer.decoder module
- RADAR.time_series.algorithms.modelsTransformersTS.informer.embed module
- RADAR.time_series.algorithms.modelsTransformersTS.informer.encoder module
- RADAR.time_series.algorithms.modelsTransformersTS.informer.masking module
- RADAR.time_series.algorithms.modelsTransformersTS.informer.model module
- Module contents
- RADAR.time_series.algorithms.modelsTransformersTS.vanillaTransformer
- Submodules
- RADAR.time_series.algorithms.modelsTransformersTS.vanillaTransformer.attn module
- RADAR.time_series.algorithms.modelsTransformersTS.vanillaTransformer.decoder module
- RADAR.time_series.algorithms.modelsTransformersTS.vanillaTransformer.embed module
- RADAR.time_series.algorithms.modelsTransformersTS.vanillaTransformer.encoder module
- RADAR.time_series.algorithms.modelsTransformersTS.vanillaTransformer.model module
- Module contents
- RADAR.time_series.algorithms.modelsTransformersTS.autoformer
- Module contents
- Subpackages
Submodules
RADAR.time_series.algorithms.transformers module
- class RADAR.time_series.algorithms.transformers.TransformersAnomalyDetection(**kwargs)[source]
Bases:
BaseAnomalyDetection- evaluate(X, y=None, threshold=None)[source]
Evaluates the model on data X (and optionally y). If no threshold is provided, it is calculated as mean + 3 * std.
- fit(X, y=None)[source]
Train Transformer model. X is the input sequence. If y is provided, it is used as target
- get_default_params(**params)[source]
Get DEFAULT parameters for this estimator, params is used to configure positional parameters in order to obtain default parameters of the object.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- get_params(**kwargs)[source]
Get parameters for this estimator.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- classmethod register_algorithm(name, model_class)[source]
Register a new algorithm in the class. :param - name: The name of the new algorithm. :type - name: str :param - model_class: The class implementing the anomaly detection model. :type - model_class: class
- The class should have:
An __init__ method that accepts model-specific parameters.
A fit(X, y) method to train the model.
A predict(X) method to make predictions.
Optionally, a decision_function(X) for scoring anomalies.
RADAR.time_series.algorithms.tsfedl module
- class RADAR.time_series.algorithms.tsfedl.TsfedlAnomalyDetection(batch_size=16, **kwargs)[source]
Bases:
BaseAnomalyDetectionBase module for any pyTorch Lightning based algorithm in TSFEDL library
- Parameters:
label_parser ((super))
values. (specific methods or operations to apply to the score)
algorithm (class object of the specific model)
model (object containing the specific model. To see the particular attributes of each model see: https://s-tsfe-dl.readthedocs.io/en/latest/index.html)
pytorch_params (dict object of pl params for the Trainer object. To see the particular attributes: https://lightning.ai/docs/pytorch/stable/common/trainer.html)
- decision_function(X)[source]
Compute the reconstruction error of X using the trained model. This can be interpreted as a performance score of the prediction.
- Parameters:
X (numpy array of shape (n_samples, seq_len, n_features)) – Input data.
- Returns:
scores – Reconstruction error per sample.
- Return type:
numpy array of shape (n_samples,)
- evaluate(X, y=None, threshold=None)[source]
Evaluate the model using decision_function (scores) and predict (outputs).
- Parameters:
X (numpy array or pandas DataFrame) – Input sequences.
y (numpy array or pandas DataFrame, optional) – Ground-truth values (for metrics).
threshold (float, optional) – Threshold to convert scores into binary labels. If None, it is computed as mean + 3 * std.
- Returns:
results –
- Dictionary containing:
”scores”: anomaly/forecasting scores.
”labels_preds”: predicted labels (if thresholding is applied).
”preds”: model predictions.
”labels_true”: ground-truth labels (if provided).
- Return type:
dict
- fit(X, y=None)[source]
Fit detector. y is ignored in unsupervised methods.
- Parameters:
X (numpy array of shape (n_samples, n_features)) – The input samples.
y (Ignored) – Not used, present for API consistency by convention.
- Returns:
self – Fitted estimator.
- Return type:
object
- get_default_params(**params)[source]
Get DEFAULT parameters for this estimator, params is used to configure positional parameters in order to obtain default parameters of the object.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- get_params()[source]
Get parameters for this estimator.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- predict(X, threshold=None)[source]
Predict anomaly labels (0 = normal, 1 = anomaly).
- Parameters:
X (array-like) – Input sequences.
threshold (float, optional) – Threshold for classification. If None, uses mean + 3*std.
- Returns:
y_pred – Binary anomaly labels.
- Return type:
numpy array of shape (n_samples,)