# Harbinger Package # version 1.0.777 source("https://raw.githubusercontent.com/cefet-rj-dal/harbinger/master/jupyter.R") #loading Harbinger load_library("daltoolbox") load_library("harbinger") #Creating dataset n <- 100 # size of each segment serie1 <- c(sin((1:n)/pi), 2*sin((1:n)/pi), 10 + sin((1:n)/pi), 10-10/n*(1:n)+sin((1:n)/pi)/2, sin((1:n)/pi)/2) serie2 <- 2*c(sin((1:n)/pi), 2*sin((1:n)/pi), 10 + sin((1:n)/pi), 10-10/n*(1:n)+sin((1:n)/pi)/2, sin((1:n)/pi)/2) event <- rep(FALSE, length(serie1)) event[c(100, 200, 300, 400)] <- TRUE dataset <- data.frame(serie1, serie2, event) #ploting the time series plot_ts(x = 1:length(dataset$serie1), y = dataset$serie1) #ploting serie #2 plot_ts(x = 1:length(dataset$serie2), y = dataset$serie2) # establishing drift method model <- hcd_eddm() # fitting the model model <- fit(model, dataset) # making detections detection <- detect(model, dataset) # filtering detected events print(detection[(detection$event),]) # evaluating the detections evaluation <- evaluate(model, detection$event, dataset$event) print(evaluation$confMatrix) # ploting the results grf <- har_plot(model, dataset$serie1, detection, dataset$event) plot(grf)