Skip to content
/ CPOP Public

Detecting changes in slope with a continuous piecewise linear model and an L0 penalty

Notifications You must be signed in to change notification settings

bastienlc/CPOP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPOP

Project for the course "Time Series" of the MVA master at ENS Paris-Saclay.

Paper : Detecting changes in slope with an L0 penalty, Robert Maidstone, Paul Fearnhead, Adam Letchford, 2017.

This project implements in python the CPOP (Continuous-piecewise-linear Pruned Optimal Partitioning) algorithm proposed in the paper above to detect changepoints in a univariate time series using a continuous piecewise linear model and an L0 penalty.

The authors made their code (in R and C++) available, but we decided to implement the algorithm from scratch in python to better understand it and to make it easier to use.

Usage

Detect changepoints in a univariate time series using the CPOP algorithm :

import numpy as np

from src import CPOP, LogCost

y = np.random.normal(size=100, scale=1)

changepoints = CPOP(y=y, beta=2 * np.log(len(y)), h=LogCost(1), sigma=1, verbose=True)

Report

The report is available here.

Code

The main code is available in the src folder. It contains an implementation of the CPOP algorithm in Python. The notebook experiments.ipynb contains the experiments we ran to test the algorithm.

Contributors

@bastienlc, @s89ne

About

Detecting changes in slope with a continuous piecewise linear model and an L0 penalty

Resources

Stars

Watchers

Forks