Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

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

Open
TLMcNulty opened this issue Jan 4, 2018 · 4 comments
Open

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

TLMcNulty opened this issue Jan 4, 2018 · 4 comments

Comments

@TLMcNulty
Copy link

TLMcNulty commented Jan 4, 2018

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
Copy link
Contributor

astanway commented Jan 4, 2018 via email

@TLMcNulty
Copy link
Author

0.22.0 I believe.

@earthgecko
Copy link

earthgecko commented Jan 4, 2018

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:

  • Mirage - allows for metrics to be analysed at multiple time resolutions beyond the FULL_DURATION which enables Skyline to handle seasonality a bit better.
  • Boundary - allows the operator confirgure thresholds for metrics and analyse these metrics for threshold breaches. On some metrics having the ability to monitor thresholds is useful.
  • Crucible - allows for ad-hoc analysis - still EXPERIMENTAL
  • Ionosphere - timeseries fingerprinting and comparsion. This allows the operator to train Skyline what is NOT anomalous and subsequently allow Skyline to learn using features profiling and comparison.
  • Panorama - an anomalies and fingerprint MySQL database

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:

  • pandas 0.17.0 deprecated the pandas.Series.iget in favour of .iloc[i] or .iat[i]
  • pandas 0.18.0 introduced a change in the Exponentially-weighted moving average function used in a number of algorithms

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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants