business-science / anomalize

Tidy anomaly detection

Home Page:https://business-science.github.io/anomalize/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Anomalize with seconds granularity

jmarc-u opened this issue · comments

Hi,

I am struggling using anomalize with my dataset where the time granularity is the second.

If I use the date (day) I can make it work as in the following example:

df <- tibble(date = seq.Date(from = as.Date("2018-03-14"), length.out = 100, by = 1), group = sample( LETTERS[1:4], 100, replace=TRUE), value = runif(100, 5.0, 7.5))

df %>% time_decompose(value, merge = TRUE, method = "twitter") %>% anomalize(remainder, method = "gesd")

Then it works:

Converting from tbl_df to tbl_time.
Auto-index message: index = date
frequency = 7 days
median_span = 50 days
A time tibble: 100 x 10
Index: date
date group value observed season median_spans remainder remainder_l1 remainder_l2 anomaly

1 2018-03-14 C 6.90 6.90 -0.144 6.04 1.01 -2.61 2.61 No
2 2018-03-15 A 5.04 5.04 -0.0231 6.04 -0.976 -2.61 2.61 No
3 2018-03-16 B 6.09 6.09 -0.0846 6.04 0.139 -2.61 2.61 No
4 2018-03-17 C 6.06 6.06 0.0353 6.04 -0.0157 -2.61 2.61 No
5 2018-03-18 D 6.77 6.77 0.0326 6.04 0.704 -2.61 2.61 No
6 2018-03-19 D 6.28 6.28 0.278 6.04 -0.0393 -2.61 2.61 No
7 2018-03-20 C 6.48 6.48 -0.0947 6.04 0.540 -2.61 2.61 No
8 2018-03-21 B 6.02 6.02 -0.144 6.04 0.124 -2.61 2.61 No
9 2018-03-22 D 5.93 5.93 -0.0231 6.04 -0.0866 -2.61 2.61 No
10 2018-03-23 C 5.78 5.78 -0.0846 6.04 -0.168 -2.61 2.61 No
... with 90 more rows

But if I try to have a dataset that combines days and time (to the second):

df <- tibble(date = seq(from = Sys.time(), length.out = 100, by = 1), group = sample( LETTERS[1:4], 100, replace=TRUE), value = runif(100, 5.0, 7.5))

df %>% time_decompose(value, merge = TRUE, method = "twitter") %>% anomalize(remainder, method = "gesd")

Then it doesn't work:

Error in filter_impl(.data, quo) : Result must have length 8, not 0

It may be the way I prepare the second dataset?
Is it supposed to work with date and time?

Thank you

I too am having this problem and it's driving me crazy. Can anyone help?