etsy / skyline

It'll detect your anomalies! Part of the Kale stack.
http://codeascraft.com/2013/06/11/introducing-kale/
Other
2.14k stars 336 forks source link

AttributeError: 'Series' object has no attribute 'iget' #123

Open TLMcNulty opened 6 years ago

TLMcNulty commented 6 years ago

When attempting to start analyzer with ./analyzer.d start the test run fails getting attributes on a series object.

Not expecting a response, going to detail my investigation here and hoped someone would post if they had any clue.


/usr/lib64/python2.7/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.
  from pandas.core import datetools
/opt/skyline/src/analyzer/algorithms.py:147: FutureWarning: pd.ewm_mean is deprecated for Series and will be removed in a future version, replace with
    Series.ewm(ignore_na=False,min_periods=0,adjust=True,com=15).mean()
  expAverage = pandas.stats.moments.ewma(series, com=15)
Algorithm test run failed.
Traceback (most recent call last):
  File "/opt/skyline/bin/../src/analyzer/analyzer-agent.py", line 47, in <module>
    ensemble = [globals()[algorithm](timeseries) for algorithm in settings.ALGORITHMS]
  File "/opt/skyline/src/analyzer/algorithms.py", line 149, in mean_subtraction_cumulation
    return abs(series.iget(-1)) > 3 * stdDev
  File "/usr/lib64/python2.7/site-packages/pandas/core/generic.py", line 3614, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'iget'
failed to start analyzer-agent```
astanway commented 6 years ago

Likely you’re using a newer version of Pandas than this supports. Which version are you using?

On Jan 3, 2018, at 9:05 PM, Tom McNulty notifications@github.com wrote:

When attempting to start analyzer with ./analyzer.d start the test run fails getting attributes on a series object.

Not expecting a response, going to detail my investigation here and hoped someone would post if they had any clue.

[user@skyline bin]# ./analyzer.d start /usr/lib64/python2.7/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead. from pandas.core import datetools /opt/skyline/src/analyzer/algorithms.py:147: FutureWarning: pd.ewm_mean is deprecated for Series and will be removed in a future version, replace with Series.ewm(ignore_na=False,min_periods=0,adjust=True,com=15).mean() expAverage = pandas.stats.moments.ewma(series, com=15) Algorithm test run failed. Traceback (most recent call last): File "/opt/skyline/bin/../src/analyzer/analyzer-agent.py", line 47, in ensemble = [globals()algorithm for algorithm in settings.ALGORITHMS] File "/opt/skyline/src/analyzer/algorithms.py", line 149, in mean_subtraction_cumulation return abs(series.iget(-1)) > 3 * stdDev File "/usr/lib64/python2.7/site-packages/pandas/core/generic.py", line 3614, in getattr return object.getattribute(self, name) AttributeError: 'Series' object has no attribute 'iget' failed to start analyzer-agent

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

TLMcNulty commented 6 years ago

0.22.0 I believe.

earthgecko commented 6 years ago

Hi @TLMcNulty

@astanway is correct it is the newer pandas version. The Etsy code is no longer functioning as the Python dependencies have started to move over the horizon. I maintain an unforked version at https://github.com/earthgecko/skyline, this version has a number of more modules with a lot more features, these include:

And the webapp UI got a bit of an upgrade too. It is a lot more complex in configuration and getting to know and run, but you cannot rush timeseries :)

Should you should just wish to just try and fix it in-situ with the Etsy version:

Replace your skyline/src/analyzer/algorithms.py with this one - https://gist.github.com/earthgecko/f1e5c4faeb9619a4b2dab0c3bc64a848

Here is the diff.

me@thing:~$ diff /tmp/etsy.algorithms.py /tmp/etsy.pandas.algorithms.py
67c67
<     test_statistic = demedianed.iget(-1) / median_deviation
---
>     test_statistic = demedianed.iat[-1] / median_deviation
81a82,87
>      # This change avoids spewing warnings on tests:
>      # RuntimeWarning: invalid value encountered in double_scalars
>      # If stdDev is 0 division returns nan which is not > grubbs_score so
>      # return False here
>      if stdDev == 0:
>          return False
131,132c137,141
<     expAverage = pandas.stats.moments.ewma(series, com=50)
<     stdDev = pandas.stats.moments.ewmstd(series, com=50)
---
>     # expAverage = pandas.stats.moments.ewma(series, com=50)
>     # stdDev = pandas.stats.moments.ewmstd(series, com=50)
>     # return abs(series.iget(-1) - expAverage.iget(-1)) > 3 * stdDev.iget(-1)
>     expAverage = pandas.Series.ewm(series, ignore_na=False, min_periods=0, adjust=True, com=50).mean()
>     stdDev = pandas.Series.ewm(series, ignore_na=False, min_periods=0, adjust=True, com=50).std(bias=False)
134c143
<     return abs(series.iget(-1) - expAverage.iget(-1)) > 3 * stdDev.iget(-1)
---
>     return abs(series.iat[-1] - expAverage.iat[-1]) > 3 * stdDev.iat[-1]
147,149c156,159
<     expAverage = pandas.stats.moments.ewma(series, com=15)
<
<     return abs(series.iget(-1)) > 3 * stdDev
---
>     # expAverage = pandas.stats.moments.ewma(series, com=15)
>     expAverage = pandas.Series.ewm(series, ignore_na=False, min_periods=0, adjust=True, com=15).mean()
>     # return abs(series.iget(-1)) > 3 * stdDev
>     return abs(series.iat[-1]) > 3 * stdDev
TLMcNulty commented 6 years ago

@earthgecko thanks a million, I'll happily dig through that project.