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

replace ADF test with Ljung-Box test for no autocorrelation #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/analyzer/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ def ks_test(timeseries):
"""
A timeseries is anomalous if 2 sample Kolmogorov-Smirnov test indicates
that data distribution for last 10 minutes is different from last hour.
It produces false positives on non-stationary series so Augmented
Dickey-Fuller test applied to check for stationarity.
It produces false positives on series with trends so Ljung-Box test for
no autocorrelation is used to filter them out.
"""

hour_ago = time() - 3600
Expand All @@ -222,8 +222,8 @@ def ks_test(timeseries):
ks_d, ks_p_value = scipy.stats.ks_2samp(reference, probe)

if ks_p_value < 0.05 and ks_d > 0.5:
adf = sm.tsa.stattools.adfuller(reference, 10)
if adf[1] < 0.05:
_, ljp = sm.stats.diagnostic.acorr_ljungbox(reference)
if ljp[-1] > 0.05:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this line broke the build. We're PEP8 compliant now - can you please take care of that extra space after 'if'?

return True

return False
Expand Down