{"action":"opened","issue":{"url":"https://api.github.com/repos/Marcnuth/AnomalyDetection/issues/11","repository_url":"https://api.github.com/repos/Marcnuth/AnomalyDetection","labels_url":"https://api.github.com/repos/Marcnuth/AnomalyDetection/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/Marcnuth/AnomalyDetection/issues/11/comments","events_url":"https://api.github.com/repos/Marcnuth/AnomalyDetection/issues/11/events","html_url":"https://github.com/Marcnuth/AnomalyDetection/issues/11","id":361897696,"node_id":"MDU6SXNzdWUzNjE4OTc2OTY=","number":11,"title":"local variable 'period' referenced before assignment--use anomaly_detect_vec?","user":{"login":"hokiegeek2","id":10785153,"node_id":"MDQ6VXNlcjEwNzg1MTUz","avatar_url":"https://avatars1.githubusercontent.com/u/10785153?v=4","gravatar_id":"","url":"https://api.github.com/users/hokiegeek2","html_url":"https://github.com/hokiegeek2","followers_url":"https://api.github.com/users/hokiegeek2/followers","following_url":"https://api.github.com/users/hokiegeek2/following{/other_user}","gists_url":"https://api.github.com/users/hokiegeek2/gists{/gist_id}","starred_url":"https://api.github.com/users/hokiegeek2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hokiegeek2/subscriptions","organizations_url":"https://api.github.com/users/hokiegeek2/orgs","repos_url":"https://api.github.com/users/hokiegeek2/repos","events_url":"https://api.github.com/users/hokiegeek2/events{/privacy}","received_events_url":"https://api.github.com/users/hokiegeek2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-19T19:38:49Z","updated_at":"2018-09-19T19:38:49Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Getting this error in the context of TS anomaly detection on a metricbeat log stream where the timestamps are all from the same day:\r\n\r\n   results.append(anomaly_detect_ts(pd.Series(item), **self._generateParams()))\r\n  File \"build/bdist.linux-x86_64/egg/anomaly_detection/anomaly_detect_ts.py\", line 207, in anomaly_detect_ts\r\nUnboundLocalError: local variable 'period' referenced before assignment\r\n\r\nI can see in the code why this is happening I am hitting the else clause with granularity of ms and period is never initialized. Logging shows why:\r\n\r\n2018-09-19 19:25:49.858000 (data.index[1]) 2018-09-19 19:25:49.180000 (data.index[0])\r\n\r\nSo from a pure computer science perspective, it's clear what's happening.\r\n    timediff = data.index[1] - data.index[0]\r\n    if timediff.days > 0:\r\n        num_days_per_line = 7\r\n        only_last = 'day' if only_last == 'hr' else only_last\r\n        period = 7\r\n        granularity = 'day'\r\n    elif timediff.seconds / 60 / 60 >= 1:\r\n        granularity = 'hr'\r\n        period = 24\r\n    elif timediff.seconds / 60 >= 1:\r\n        granularity = 'min'\r\n        period = 1440\r\n    elif timediff.seconds > 0:\r\n        granularity = 'sec'\r\n        # Aggregate data to minutely if secondly\r\n        data = data.resample('60s', label='right').sum()\r\n    else:\r\n        granularity = 'ms'\r\n\r\nThe questions: \r\n\r\n1. Should I change the sampling so that get data points every 1-5 minutes, or should I consider anomaly_detect_vec?\r\n\r\n2. More fundamentally, I was thinking that period refers to the window for the data (i.e., 1 hr, 1 day, etc...) irrespective of how many data points in that window. Is this not the case?\r\n\r\nAny guidance is very much appreciated, thanks!\r\n\r\n--John"}}
{"actor":{"display_login":"hokiegeek2"}}