Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outlier detection failed: issue with reading timestamps? #98

Closed
statsguy1995 opened this issue Jul 29, 2021 · 4 comments
Closed

Outlier detection failed: issue with reading timestamps? #98

statsguy1995 opened this issue Jul 29, 2021 · 4 comments

Comments

@statsguy1995
Copy link

statsguy1995 commented Jul 29, 2021

I have a pandas dataframe dat with two columns, the first one having timestamps, named 'time', and the second one containing the data values, named 'value'. The timestamps have a frequency of 5 min i.e. the values there are of the type "2018-01-01 00:00:00", "2018-01-01 00:05:00", "2018-01-01 00:10:00", etc.

I invoked kats.TimeSeriesData() on this dataset, then apply outlier detection.
Code run by me:
dat['time'] = pd.to_datetime(dat['time']) #converting timestamp column to pandas datetime
dat_ts = TimeSeriesData(dat)
from kats.detectors.outlier import OutlierDetector
ts_outlierDetection = OutlierDetector(dat_ts, 'additive') # call OutlierDetector
ts_outlierDetection.detector()

I get the following error on running the last line.

ERROR:root:!! Traceback (most recent call last):
!! File ".../kats/detectors/outlier.py", line 114, in detector
outlier = self.__clean_ts__(ts)
!! File ".../kats/detectors/outlier.py", line 88, in __clean_ts__
result = seasonal_decompose(original, model=self.decomp)
!! File ".../pandas/util/_decorators.py", line 207, in wrapper
return func(*args, **kwargs)
!! File ".../statsmodels/tsa/seasonal.py", line 140, in seasonal_decompose
pfreq = freq_to_period(pfreq)
!! File ".../statsmodels/tsa/tsatools.py", line 829, in freq_to_period
raise ValueError("freq {} not understood. Please report if you "
!! ValueError: freq T not understood. Please report if you think this is in error.
ERROR:root:Outlier Detection Failed

I looked into line 829 of tsatools.py and it seems it can only support few timestamp formats and hence not recognizing the 5 min frequency in my timeseries data? Should I be setting something like freq='5min' somewhere in the codes?

I also ran the outlier detection code on daily data, i.e. freq = 'D', and there seems to be no issues (this is essentially the example in the tutorial).

@Axemen
Copy link
Contributor

Axemen commented Jul 31, 2021

Hey @statsguy1995,

At the moment anything in KATS that use seasonal decomposition (Such as the OutlierDetector) all rely on the statsmodels library for the decomposition. And at the moment they do not support intra-day frequencies for decomposition.

@mturk24
Copy link

mturk24 commented Aug 27, 2021

Hi, I wanted to follow up to see if intraday frequencies will be available at all, and if so is there an estimated time in future?

@milton-logothetis
Copy link

@Axemen Are you familiar of any workarounds for supplying custom frequency to the underlying seasonal_decompose so that it doesn't fail? That is without manually changing the source code.

@Axemen
Copy link
Contributor

Axemen commented Oct 7, 2021

Hey @milton-logothetis,

At the moment there is no workaround without changing the underlying code.

It is possible to supply custom frequencies to the seasonal_decompose function through the period argument, However, Kats has no way of passing it through at the moment. But this is something that can be added in the future.

@rohanfb rohanfb closed this as completed Feb 14, 2022
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

No branches or pull requests

5 participants