MLBazaar / MLBazaar/MLPrimitives

Bug in timeseries_anomalies function called regression_errors

Open
#148 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Pending Review
Dominant language
Python
Stars
70
Forks
37
PR merge metrics
No merged PRs in 30d

Description

What I Did

I ran a pipeline with signal T-10 from the publicly available NASA Telemanom signal. My train/test split was 571 training samples and 24 testing samples. The code seems to be breaking because the span in ewm is int(len(y)*smoothing_window) = int(24*0.01) = int(0.24) = 0 which is less than 1. As per the pandas documentation span >= 1 (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.ewm.html)

One way to fix this is to add a max(1, int(len(y)*smoothing_window)) so that we never go below 1 for the span.

Traceback:
Traceback (most recent call last):
  File "run_pipelines.py", line 76, in <module>
    anoms = pipeline.predict(test)
  File "/home/itinawi/meng/venv/lib/python3.5/site-packages/mlblocks/mlpipeline.py", line 264, in predict
    outputs = block.produce(**produce_args)
  File "/home/itinawi/meng/venv/lib/python3.5/site-packages/mlblocks/mlblock.py", line 268, in produce
    return self.primitive(**produce_args)
  File "/home/itinawi/meng/IML-private/Orion/analysis/timeseries_anomalies.py", line 33, in regression_errors
    return pd.Series(errors).ewm(span=smoothing_window).mean().values
  File "/home/itinawi/meng/venv/lib/python3.5/site-packages/pandas/core/generic.py", line 8927, in ewm
    adjust=adjust, ignore_na=ignore_na, axis=axis)
  File "/home/itinawi/meng/venv/lib/python3.5/site-packages/pandas/core/window.py", line 2489, in ewm
    return EWM(obj, **kwds)
  File "/home/itinawi/meng/venv/lib/python3.5/site-packages/pandas/core/window.py", line 2074, in __init__
    self.com = _get_center_of_mass(com, span, halflife, alpha)
  File "/home/itinawi/meng/venv/lib/python3.5/site-packages/pandas/core/window.py", line 2389, in _get_center_of_mass
    raise ValueError("span must satisfy: span >= 1")
ValueError: span must satisfy: span >= 1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in analysis/timeseries_anomalies.py at the regression_errors call to pandas ewm, then reproduce the failure with the NASA Telemanom T-10 split described here. Verify that the smoothing span remains valid for the 24-sample test set and that the pipeline completes without the reported ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
machine-learning
Issue type
Bug
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.