ts_benchmark.baselines.merlion package

The following module is the adapter required for embedding the merlion models into TFB.

ts_benchmark.baselines.merlion.merlion_models module

Functions

generate_model_factory(model_name, ...)

Generate model factory information for creating Merlion model adapters.

Classes

MerlionModelAdapter(model_name, model_class, ...)

Merlion model adapter class, used to adapt models in the Merlion framework to meet the requirements of prediction strategies.

class MerlionModelAdapter(model_name: str, model_class: type, config_class: type, model_args: dict, allow_label_on_train: bool)[source]

Bases: object

Merlion model adapter class, used to adapt models in the Merlion framework to meet the requirements of prediction strategies.

detect_fit(series: pandas.DataFrame, label: pandas.DataFrame) object[source]

Fit a suitable Merlion model on time series data.

Parameters:
  • series – Time series data.

  • label – Label data.

Returns:

The fitted model object.

detect_label(train: pandas.DataFrame) numpy.ndarray[source]

Use the adapted Merlion model for anomaly detection and generate labels.

Parameters:

train – Training data used for anomaly detection.

Returns:

Anomaly label array.

detect_score(train: pandas.DataFrame) numpy.ndarray[source]

Calculate anomaly scores using the adapted Merlion model.

Parameters:

train – Training data used to calculate scores.

Returns:

Anomaly score array.

generate_model_factory(model_name: str, model_class: object, config_class: object, required_args: dict, allow_label_on_train: bool) object[source]

Generate model factory information for creating Merlion model adapters.

Parameters:
  • model_name – Model name.

  • model_class – Merlion model class.

  • config_class – Merlion configuration class.

  • required_args – Required parameters for model initialization.

  • allow_label_on_train – Whether to use labels during training.

Returns:

A dictionary containing the model factory and required parameters.