Skip to content

Conversation

@Reinaldo-Kn
Copy link

As mentioned in the issue #39

New Functions in _alarms.py

This module introduces several functions designed to detect trends, outliers, bias, and anomalies in time series data. Each function operates on array-like inputs and returns alarm indicators based on specific criteria.

  • detectTrend(data, window_size=5)

Detects the trend in the provided data using a moving average.

Parameters:

    data: array-like
        The input data to be analyzed.
    window_size: int, optional
        The size of the moving window to calculate the trend. Default is 5.

Returns:

    alarm: ndarray
        An array indicating the trend (1 for positive trend, -1 for negative trend, 0 for no trend).
  • detectMovingWindowOutlier(data, window_size=10, count_limit=1)

Detects outliers in a moving window of the data.

Parameters:

    data: array-like
        The input data to be analyzed.
    window_size: int, optional
        The size of the moving window to analyze. Default is 10.
    count_limit: int, optional
        The maximum number of outliers allowed within the window. Default is 1.

Returns:

    alarm: ndarray
        An array indicating if the count of outliers exceeds the count_limit within each window (1 for alarm, 0 for no alarm).
  • detectBias(data, expected_value, threshold=0.1)

Detects bias in the data by comparing the mean to an expected value.

Parameters:

    data: array-like
        The input data to be analyzed.
    expected_value: float
        The expected mean value to compare against.
    threshold: float, optional
        The threshold for deviation from the expected value. Default is 0.1.

Returns:

    alarm: ndarray
        An array indicating if the bias exceeds the threshold (1 for alarm, 0 for no alarm).

  • detectNelsonRules(data, threshold=1)

Detects anomalies in the data based on Nelson Rules 1, 2, and 3.

Parameters:

    data: array-like
        The input data to be analyzed.
    threshold: float, optional
        The multiplier for the standard deviation in anomaly detection. Default is 1.

Returns:

    alarms: dict
        A dictionary with alarms for each rule (1 for alarm, 0 for no alarm):
            rule_1: Alarms for rule 1.
            rule_2: Alarms for rule 2.
            rule_3: Alarms for rule 3.

You can view the new functions in Colab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants