From 565b056715c6d74ddf43cf1246d3425ca8e8bde0 Mon Sep 17 00:00:00 2001 From: Anton Lebedevich Date: Sat, 19 Oct 2013 21:10:15 +0400 Subject: [PATCH 1/2] replace ADF test with Ljung-Box test for no autocorrelation --- src/analyzer/algorithms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/analyzer/algorithms.py b/src/analyzer/algorithms.py index 0a0fca72..8ce1bf6a 100644 --- a/src/analyzer/algorithms.py +++ b/src/analyzer/algorithms.py @@ -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 @@ -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: return True return False From 42b0b6f02e5b2293e4b77656f5e9ba0b9d2339b4 Mon Sep 17 00:00:00 2001 From: Anton Lebedevich Date: Sat, 26 Oct 2013 22:24:10 +0400 Subject: [PATCH 2/2] remove extra space after keyword --- src/analyzer/algorithms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyzer/algorithms.py b/src/analyzer/algorithms.py index 8ce1bf6a..b336ede5 100644 --- a/src/analyzer/algorithms.py +++ b/src/analyzer/algorithms.py @@ -223,7 +223,7 @@ def ks_test(timeseries): if ks_p_value < 0.05 and ks_d > 0.5: _, ljp = sm.stats.diagnostic.acorr_ljungbox(reference) - if ljp[-1] > 0.05: + if ljp[-1] > 0.05: return True return False