Giter Club home page Giter Club logo

binsegrcppmeanvar's Introduction

binsegRcpp Efficient implementation of the binary segmentation heuristic algorithm for changepoint detection, using C++ std::multimap.

testshttps://travis-ci.org/tdhock/binsegRcpp.png?branch=master
coveragehttps://coveralls.io/repos/tdhock/binsegRcpp/badge.svg?branch=master&service=github

Installation

install.packages("binsegRcpp")
##OR
if(require("remotes"))install.packages("remotes")
remotes::install_github("tdhock/binsegRcpp")

Usage

The main function is binseg_normal which takes arguments:

  • data.vec is a numeric vector of data to segment.
  • max.segments is a positive integer, the maximum number of segments to consider (by default equal to the number of data points).
> x <- c(0.1, 0, 1, 1.1, 0.1, 0)
> (models.dt <- binsegRcpp::binseg_normal(x))
   segments         loss end before.mean after.mean before.size after.size
1:        1 1.348333e+00   6   0.3833333         NA           6         NA
2:        2 1.015000e+00   4   0.5500000       0.05           4          2
3:        3 1.500000e-02   2   0.0500000       1.05           2          2
4:        4 1.000000e-02   5   0.1000000       0.00           1          1
5:        5 5.000000e-03   1   0.1000000       0.00           1          1
6:        6 4.440892e-16   3   1.0000000       1.10           1          1
   invalidates.index invalidates.after
1:                NA                NA
2:                 1                 0
3:                 2                 0
4:                 2                 1
5:                 3                 0
6:                 3                 1

The table above contains all of the data that are computed during the binary segmentation algorithm. It has a special class with dedicated methods:

> class(models.dt)
[1] "binseg_normal" "data.table"    "data.frame"   
> methods(class="binseg_normal")
[1] coef plot
see '?methods' for accessing help and source code

The coef methods returns a data table of segment means:

> coef(models.dt, segments=2:3)
   segments start end mean
1:        2     1   4 0.55
2:        2     5   6 0.05
3:        3     1   2 0.05
4:        3     3   4 1.05
5:        3     5   6 0.05

Related work

This version uses the Rcpp/.Call interface whereas the binseg package uses the .C interface.

See branches for variations of the interface to use as test cases in RcppDeepState development.

binsegrcppmeanvar's People

Contributors

diego-urgell avatar tdhock avatar

Stargazers

 avatar  avatar  avatar

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.