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.
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)
The report is available here.
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.