Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Cost function equivalent to R changepoint library cpt_meanvar #148

Closed
drandynisbet opened this issue Apr 19, 2021 · 3 comments

Comments

@drandynisbet
Copy link

drandynisbet commented Apr 19, 2021

Hi,
apologies in advance if I've missed something obvious, I'm using ruptures more as a black-box user - and have only started to dabble with changepoint analysis relatively recently. Could you outline what's required to implement, or whether you might release support for a cost-function covering both mean and variance that would give similar results to the R cpt_meanvar?
I'm using PELT to examine some observations from tracing the performance of applications when they are in execution.

Thanks,
Andy

@oboulant
Copy link
Collaborator

Hi @drandynisbet ,

Thanks for you interest in ruptures !

Why not checking for instance Cost Normal that do detect changes in the mean and covariance matrix of a sequence of multivariate Gaussian random variables ?

For instance :

import ruptures as rpt
import numpy as np
from numpy.random import RandomState
import matplotlib.pyplot as plt  # for display purposes

rd = RandomState(1234)
segment_length = 100

signal = np.r_[rd.normal(0, 0.1, segment_length), 
        rd.normal(0, 0.01, segment_length),
        rd.normal(1, 0.05, segment_length)]


algo = rpt.Pelt(model="normal", min_size=1, jump=1).fit(signal)
my_bkps = algo.predict(pen=100)
print(my_bkps)

fig, ax = rpt.display(signal, [100, 200, 300], my_bkps)
plt.show()

Which outputs :
Figure_1

@deepcharles
Copy link
Owner

As mentionned by @oboulant, this cost function will simultaneously detect changes in the mean and variance/covariance matrix for multidimensional signals. This should emulate the behaviour of cpt_meanvar.

@oboulant
Copy link
Collaborator

I am closing the issue. Feel free re-open one or a discussion thread if needed !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants