Linkedin Luminol Anomaly Detection and Correlation Working Example

Github Link Of Luminol Library: https://github.com/linkedin/luminol

Can someone explain to me a sample code on how to use this module to detect anomalies in a dataset.

I want to use this module to detect anomalies in time series data.

PS: I tried example 1 specified in README.md, but received an error, so please provide me with a working example for detecting anomalies.

Example 1 Put anomaly ratings on the list.

from luminol.anomaly_detector import AnomalyDetector my_detector = AnomalyDetector(ts) score = my_detector.get_all_scores() anom_score = list() for (timestamp, value) in score.iteritems(): t_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)) anom_score.append([t_str, value]) 

Error getting value: (22, "Invalid argument") On line: t_str = time.strftime ('% Y-% m-% d% H:% M% S', time.localtime (timestamp))

Using Python 2.7

Thanks:)

+5
source share
1 answer

The example works after adding import time and defining ts . Using time.localtime assumes your source data uses unix time. Additional options for AnomalyDetector are noted here . Available algorithms are defined here . If algorithm_name not specified, AnomalyDetector reverts to using default_detector , which uses a weighted sum of exponential averages and derivatives . These slides may also be helpful.

data.csv

 1490323038, 3 1490323048, 4 1490323058, 6 1490323068, 78 1490323078, 67 1490323088, 5 

app.py

 from luminol.anomaly_detector import AnomalyDetector import time # ts = 'data.csv' # or ts = { '1490323038': 3, '1490323048': 4, '1490323058': 6, '1490323068': 78, '1490323078': 67, '1490323088': 5, } my_detector = AnomalyDetector(ts) score = my_detector.get_all_scores() anom_score = [] for (timestamp, value) in score.iteritems(): t_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)) anom_score.append([t_str, value]) for score in anom_score: print(score) 

Output:

 ['2017-03-23 19:37:18', 0.0] ['2017-03-23 19:37:28', 0.02482518793211144] ['2017-03-23 19:37:38', 0.06951052620991202] ['2017-03-23 19:37:48', 2.5187085350547482] ['2017-03-23 19:37:58', 1.201340494410737] ['2017-03-23 19:38:08', 0.9673414624904575] 
+1
source

Source: https://habr.com/ru/post/1263874/


All Articles