Giter VIP home page Giter VIP logo

breakoutdetection's People

Contributors

akejariwal avatar caniszczyk avatar eddelbuettel avatar harsha2010 avatar haseebr avatar putnam120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

breakoutdetection's Issues

install BreakoutDetection offline

I tried to install BreakoutDetection offline per https://stackoverflow.com/questions/33179156/installing-a-package-offline-from-github and got error:

source <- devtools:::source_pkg("/Users/abc/BreakoutDetection-master")
install(source)

Error in eapply(ns_env(pkg), force, all.names = TRUE) : 
  cannot open file '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BreakoutDetection/R/BreakoutDetection.rdb': No such file or directory
In addition: Warning message:
In eapply(ns_env(pkg), force, all.names = TRUE) :
  restarting interrupted promise evaluation

Any idea? Thanks.

R failed to load BreakoutDetection

My System Parameters:
MacBookPro, Mac OSX 10.8.5
RStudio Version 0.98.1049, R Version 3.1.1
I installed Command Line Tools via Apple Developer Website for Mountain Lion

R Commands Follow:
devtools::install_github("twitter/BreakoutDetection")
library(BreakoutDetection)

Generated following error:
1 error generated.
make: *** [edm-multi.o] Error 1
ERROR: compilation failed for package ‘BreakoutDetection’

Any ideas what is going wrong? Really want to use this tool.

Recommended install fails

Trying to install based on reccomended pattern with Anaconda:

Rscript -e "devtools::install_github("twitter/BreakoutDetection")"
Error in lapply(repo, github_remote, username = username, ref = ref, subdir = subdir,  : 
  object 'twitter' not found
Calls: <Anonymous> -> lapply
Execution halted

Rust and Ruby versions

Hey, just wanted to let you know there are now versions of BreakoutDetection in Rust and Ruby.

fwiw, the Rust compiler found this assignment to qb isn't used and can be removed.

Thanks for this library!

compilation failed -- Ubuntu 14.04 and Revolution R Open

Unfortunately I cannot compile the package on the following setup:

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

Revolution R Open 8.0 beta
The enhanced R distribution from Revolution Analytics
Visit mran.revolutionanalytics.com/open for information
about additional features and technical support options.

library(devtools)
devtools::install_github("twitter/BreakoutDetection")
Downloading github repo twitter/BreakoutDetection@master
Error in system(full, intern = quiet, ignore.stderr = quiet, ...) :
error in running command

Sys.info()
sysname
"Linux"
release
"3.13.0-37-generic"
version
"#64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014"
nodename
"Inspiron-3520"
machine
"x86_64"

Any suggestion or ideas? Thanks!

R code results do not match C++ code results (version: multi)

On the same scribe data input:
105.08333,90.90000,763.90000,83.36667,78.36667,80.58333,76.36667,210.98333,78.00000,77.51667,83.01667,89.23333,84.86667,653.16667,70.91667,72.83333,75.91667,73.53333,548.86667,66.23333,73.45000,66.96667,71.11667,68.31667,285.38333,317.20000,63.28333,64.08333,60.50000,550.88333,399.68333,75.90000,115.35000,78.93333,88.68333,475.53333,30.11667,31.51667,34.08333,39.55000,47.51667,423.63333,52.55000,50.21667,61.41667,56.61667,64.41667,742.30000,165.85000,122.88333,122.21667,114.66667,565.96667,134.70000,141.16667,160.78333,168.48333,458.65000,513.28333,154.36667,130.66667,125.93333,127.25000,615.58333,122.90000,97.45000,122.76667,115.10000,111.95000,442.78333,113.83333,116.11667,128.70000,135.03333,138.75000,153.38333,143.58333,161.50000,168.11667,152.25000,147.11667,163.91667,161.10000,146.95000,132.65000,127.28333,116.10000,92.28333,54.88333,111.35000,114.98333,110.98333,1015.35000,774.58333,232.65000,134.61667,130.25000,98.66667,102.40000,184.86667,258.76667,70.33333,81.38333,81.10000,89.21667,536.96667,85.83333,95.63333,76.10000,94.38333,73.25000,346.70000,65.38333,84.73333,140.56667,120.60000,121.38333,359.23333,55.28333,54.55000,52.18333,56.20000,112.11667,208.53333,49.40000,49.06667,56.06667,54.01667,63.51667,344.41667,42.06667,55.36667,55.96667,55.85000,56.30000,46.56667,49.25000,43.90000,357.61667,44.10000,44.68333,43.13333,40.55000,452.20000,47.06667,40.00000,42.35000,48.36667,44.86667,48.51667,244.01667,50.16667,48.73333,47.91667,51.96667,343.33333,35.25000,45.33333,46.86667,48.78333

The R version returns 47, 87 for
res = breakout(Scribe, min.size=24, method='multi', beta=.001, degree=1, plot=TRUE)
while the C++ multi version returns 26, 51, 76, 101 for edm_multi(scribeData, 24, 0.001, new Linear).

Shouldn't both return the same as the R code?

Breakout detection in conjunction with Anomaly Detection

Hello,
I am using the AnomalyDetection package and was wondering if the changepoints detected by breakout can be used in any way to determine the long_term period parameter of Anomaly Detection.
Any guidance is greatly appreciated, as I am a little lost here.

Changing the Default Plot Style

Thanks for building and open sourcing the package. I've found that the default plot generated does not allow the viewer to easily compare the mean shifts across different time periods and gauge the magnitude of the shift. The example plot shown in the blog works well for this particular use-case.

I've been able to modify the plotting section in EDM.R to produce this plot instead of the default one
rplot

If you think this use-case is potentially useful to other users of the package, would you accept a PR?

Segfault with constant input and `exact=F`

Tested on two linux machines (rehel and ubuntu) with R3.1.1.

> library(BreakoutDetection)
> breakout(rep.int(20, 1000),  exact = F)

 *** caught segfault ***
address 0xfffffffc039ffa30, cause 'memory not mapped'

Traceback:
 1: .Call("BreakoutDetection_EDM_tail", PACKAGE = "BreakoutDetection",     Z, min_size, alpha, quant)
 2: Analysis(Zcounts, min.size, alpha)
 3: breakout(rep.int(20, 1000), exact = F)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Question regarding ForwardUpdate

I'm currently going through the source and I'm having trouble to understand how interval tree A is updated in ForwardUpdate: As far as I understand it, the idea is to move the location candidate one step to the right (Line 198) and then update the trees by removing distances related to the point on the left which is now outside the window and by adding distances related to the point on the right which is now inside the window.

Since the window for tree A contains min_size points, I think we should add and remove min_size - 1 distances from tree A, respectively. However, as far as I understand lines 201-219, the code actually does the following:

  • Add the min_distance - 1 distances from Z[tau1 - min_size] - Z[tau1 - 1] through Z[tau1 - 2] - Z[tau1 - 1] (inclusive). So far so good.
  • Remove the min_distance (!) distances from Z[tau1 - min_size] - Z[tau1 - min_size - 1] through Z[tau1 - 1] - Z[tau1 - min_size - 1] (inclusive). I don't think that last distance should be removed here, since Z[tau1 - 1] is the new point and Z[tau1 - min_size - 1] is the point that was just dropped.
  • Add the single distance Z[tau1 - min_size - 1] - Z[tau1 - min_size]. I don't think that's correct: this is a distance related to the point we just dropped, so it should be removed. In addition, we just did remove it in the previous step!

I therefore think that the loop in line 208 should have the limit i < tau1 - 1 (just as the loop before it) and that the addition of the single distance after it (lines 215-219) should be removed.

Is this reasoning correct or did I miss something?

can't compile

Hi, getting lots of compile errors upon attempt to install. Errors are as follows:

Downloading github repo twitter/BreakoutDetection@master
Installing BreakoutDetection
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla
CMD INSTALL
'/private/var/folders/dl/8t8_l9js3k57d_qxtg3803040000gn/T/RtmpEARTEo/devtools1f640e4eb38/twitter-BreakoutDetection-1342ed4'
--library='/Library/Frameworks/R.framework/Versions/3.1/Resources/library'
--install-tests

  • installing source package ‘BreakoutDetection’ ...
    ** libs
    g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o
    couldn't understand kern.osversion 14.0.0' g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c edm-multi.cpp -o edm-multi.o couldn't understand kern.osversion14.0.0'
    edm-multi.cpp: In function ‘Rcpp::List EDM_multi(const Rcpp::NumericVector&, int, double, int)’:
    edm-multi.cpp:72: error: call of overloaded ‘pow(int, int)’ is ambiguous
    /usr/include/math.h:443: note: candidates are: double pow(double, double)
    /usr/include/c++/4.2.1/cmath:357: note: float std::pow(float, float)
    /usr/include/c++/4.2.1/cmath:361: note: long double std::pow(long double, long double)
    /usr/include/c++/4.2.1/cmath:365: note: double std::pow(double, int)
    /usr/include/c++/4.2.1/cmath:369: note: float std::pow(float, int)
    /usr/include/c++/4.2.1/cmath:373: note: long double std::pow(long double, int)
    make: *** [edm-multi.o] Error 1
    ERROR: compilation failed for package ‘BreakoutDetection’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/BreakoutDetection’
    Error: Command failed (1)

RStudio Error in Compilation

I was getting an issue when I was trying to directly install BreakoutDetection in RStudio. It was prompting me to install RBuildTools which I already had. Seems like there is a hard-coded path reference to "c:/Rtools/mingw_64/bin/g++" . If you copy the RBuildTools (currently in C:\RBuildTools for me), the library compiles fine. I couldn't find which makefile was making that reference call.

I am on windows 10 x64.

Bug in pval computation

Hello,

I am having difficulty retrieving pvals when method='amoc'.

Looking at this chunk (lines 92-97 in EDM.R):

            over = 1
            for(i in 1:nperm){
                Zcounts = sample(Zcounts)
                stat = Analysis(Zcounts, min.size, alpha)
                if(stat$stat >= retList$stat)
                    over = over + 1

I don't believe retList has been initialized. So stat$stat >= retList$stat is always false. Indeed,
running breakout with nperm=N results in a p-value of 1/(N+1).

Forgive me if I'm pointing out something incorrect or already known. I couldn't find any mention of it here.

There is no package called 'stringi'

Folks,
Any help on this configuration issue appreciated. It looks like stringi did not install with devtools

Running R version 3.2.2 (2015-08-14) on a Windows 6 through the Shiny interface

devtools::install_github("twitter/BreakoutDetection")
Downloading GitHub repo twitter/BreakoutDetection@master
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘stringi’

Unable to plot results

I am trying to use the instructions to detect anomolies on my file. The data has pageviews per day for last 4 years. Please find it attached.
2.zip

When I use the command :
data <- read.csv("2.csv")
res = breakout(data, min.size=24, method='amoc', beta=0.001, degree=1, plot=TRUE)
res$plot

I am getting this error
Error: Invalid input: time_trans works with objects of class POSIXct only

This works fine on the sample data, but is not working on my data file.

Is it any compatibility issue or do I need to format my data in a different way? Any help would be greatly appreciated.

Potentail bug while calculating approxmiate median

Line 65 of this file edmTail.cpp contains the following line
return lWeight*(quant*(lu-l)+l) + rWeight*(quant*(u-rl)+rl);
where

lu = (u+l)/2;
rl = (u+lu)/2;

This seems wrong. Shouldn't this be:
return lWeight*(quant*(lu-l)+l) + rWeight * (quant*(u-lu)+lu);

Simple visulization of the problem:
say we have the line return lWeight * ML + rWeight * MR;
The current implementation is returning the first case while it should be the second case.

l.....................ML..................... lu ......................rl.............MR.............u

l.....................ML.................... lu ......................MR..........................u

fail to install

Below is the error i get when i try to install breakout detection for R on macbook

  • installing source package ‘BreakoutDetection’ ...
    ** libs
    sh: make: command not found
    ERROR: compilation failed for package ‘BreakoutDetection’

Questions about edm-multi

I've been going through the code for edm-multi.cpp, and I some general confusion about the algorithm being carried out. I'll keep my questions limited at first so that perhaps the answers to them can alleviate my confusion on the rest.

  1. Is the statistic used in the algorithm to detect multiple breakouts (in edm-multi.cpp) to measure the significance of a breakout at a certain point the same as in that for detection of a at most one breakout (i.e. in edmTail.cpp)? I feel like I understand the process used in edmTail, especially thanks to the paper written introducing the breakout detection algorithm. But it looks like edm-multi measures something slightly different--as best as I can tell it's looking for a shift in the median with some sort of optional penalization.
  2. Is it possible to get some explanation as to what is going on in lines 73-78 of edm-multi.cpp? I think one of the main things confusing me about this is the F[t] term in the definition of tmp. It seems like this would have an unwanted accumulative effect on the statistic.
  3. Am I correct in saying that when *G = Quadratic, breakouts that occur earlier in the time series are favored more than those that occur later? It seems like the more breakouts that have been observed, the more this term will penalize the tmp statistic.

Assumption of independence observations over time

Good morning,
I find this methods very interesting, but looking at the original paper, and also at the theory behind the previous version of the technique (in the package 'ecp'), I see that there is the assumption of independent observations over time, which is quite restrictive in the context of time series. How would you suggest to deal with that? I checked and some of the examples proposed do not actually perfectly follow this assumption since there is some autocorrelation in the data.
Thank you

Compilation problem related to Rcpp

Hi!

Thanks for this interesting package. However, I cannot install it because there is a problem with the Rcpp package. Can anyone help me with this?

* installing *source* package 'BreakoutDetection' ...
** libs
[... left out part... ]

RcppExports.cpp:4:18: fatal error: Rcpp.h: No such file or directory
compilation terminated.
make: *** [RcppExports.o] Error 1

[... left out part ...]

ERROR: compilation failed for package 'BreakoutDetection'
Error: Command failed (1)

'Interesting' behaviour in EDM-X when data has a small SD

I found some unusual behavior as the standard deviation of some test data (on either side of a step change) drops.

When the sd is less than 1, the detection of the change becomes inaccurate - in a very defined manner. [EDIT: I'd note that the '1' is a big coincidence - the knee changes as the data range changes, as you might expect]

See the below. My data actually changes at point 500, EDM-X finds this to within two intervals above that and is out by 50 intervals below.

I'd be interested in any comments on this...

library(BreakoutDetection)

# Try EDM-X on SDs over a (log) range
logSds <- seq(from=-0.2, to=0.2, by=.05)
sds <- 10 ^ logSds
errs <- vector(,length(sds))

erri <- 1
for(i in logSds) {
  sd <- 10 ^ i

  set.seed(123)
  # construct datasets
  s1 <- zoo(rnorm(500,mean=100,sd=sd), seq.POSIXt(as.POSIXlt("2016-01-01"), by=3600,length.out=500))
  s2 <- zoo(rnorm(400,mean=110,sd=sd), seq.POSIXt(as.POSIXlt("2016-01-21 20:00:00"), by=3600,length.out=400))

  st <- rbind(s1, s2)

  zdata <- data.frame(timestamp=time(st), count=as.vector(st))

  br <- breakout(zdata,min.size=100, method='amoc', plot=T)

  errs[erri] <- abs(br$loc - 500)
  erri <- erri + 1
}

plot(sds, errs)

compilation failed

I got this compilation error on

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Platform: x86_64-w64-mingw32/x64 (64-bit)

install.packages("devtools")
Installing package into ‘C:/Users/FG/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.stat.unipd.it/bin/windows/contrib/3.1/devtools_1.5.zip'
Content type 'application/zip' length 254956 bytes (248 Kb)
opened URL
downloaded 248 Kb

package ‘devtools’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\FG\AppData\Local\Temp\RtmpsJoQab\downloaded_packages

devtools::install_github("twitter/BreakoutDetection")
Installing github repo BreakoutDetection/master from twitter
Downloading master.zip from https://github.com/twitter/BreakoutDetection/archive/master.zip
Installing package from C:\Users\FG\AppData\Local\Temp\RtmpsJoQab/master.zip
Installing BreakoutDetection
"C:/PROGRA1/R/R-311.1/bin/x64/R" --vanilla CMD INSTALL
"C:\Users\FG\AppData\Local\Temp\RtmpsJoQab\devtoolsc54adb57d4\BreakoutDetection-master"
--library="C:/Users/FG/Documents/R/win-library/3.1" --install-tests

  • installing source package 'BreakoutDetection' ...
    ** libs
    Warning: running command 'make -f "C:/PROGRA1/R/R-311.1/etc/x64/Makeconf" -f "C:/PROGRA1/R/R-311.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="BreakoutDetection.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o edm-multi.o edm-per.o edmTail.o edmx.o helper.o"' had status 127
    ERROR: compilation failed for package 'BreakoutDetection'
  • removing 'C:/Users/FG/Documents/R/win-library/3.1/BreakoutDetection'
    Error: Command failed (1)

Poor performance: speed and accuracy

Hi,

I have tried the code and maybe I'm doing something wrong but the performance is not very good in my case. I have tried it with a signal of 118.796 points that has very clear ramps. The result is not very accurate and in addition the program requires more than 2 hours to obtain the result.

On the other hand, I have tried the same data with Matlab 2016b (function findchangepts( ) ) and the result is obtained in less than 1 second, with much better accuracy.

Attached there are:

  • the signal: MyData.csv
  • the result of BreakoutDetection
  • the result of Matlab

Code R:

mydata = read.table("MyData.csv", header=FALSE)
x = unlist(mydata)
myRes = breakout(x, min.size=66, method='multi', beta=0.001, degree=1, plot=FALSE)

Code Matlab:

x = load('MyData.csv');
[ipt,residual] =findchangepts(x, 'Statistic','linear','MinDistance', 66,'MinThreshold',100);

MyData.zip

twitterbreakoutresult

matlabresult

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.