hildensia / bayesian_changepoint_detection

Methods to get the probability of a changepoint in a time series.
MIT License
670 stars 213 forks source link

Bayesian online changepoint detection for multivariate data #11

Closed sokolov-alex closed 3 years ago

sokolov-alex commented 8 years ago

Is it possible to make Ryan Adams algorithm to work on multivariate data too?

hildensia commented 8 years ago

As far as I can see, the change should be relatively easy, but a bit time consuming. It's only updating the student t distribution to handle multivariate data correctly. It is not yet in scipy, though, AFAIK, so it would need a bit of time to get it in there.

Would you feel confident enough to translate e.g. the wiki article on multivariate student t distributions to a scipy.stats.multivariate_t?

sokolov-alex commented 8 years ago

I have found a multivariate student t distribution implementation, but I didn't yet find out how to change the update_theta function to handle multivariate data.

mathDR commented 8 years ago

You would want to mimic numpy.random.multivariate_normal as that is the main call from scipy.stats.multivariate_normal (the rest is type and size checking). If we just want a local version, that should be fine.

luhgit commented 7 years ago

Hi @sokolov-alex : Did you find a way to update the theta function?

vickyf commented 6 years ago

Depending on your goal it might be good enough to implement a multivariate T, which assumes the input variables to be independent. Though this will not capture a change in covariance structure, it might still be useful depending on what you are looking for. On top of that the implementation of this is rather simple.

Sandy4321 commented 6 years ago

Hello friends, as I can see: Modeling Changing Dependency Structure in Multivariate Time Series So you already added this functionality to detect a change in multivariate time series? it would great to have it. Let's say I have 9 time series and small change happen in which of them. This change is not enough to detect by analyzing each one individually, but some aggregation may help?
Or 5 of them changed and 4 not, so still change will be detected with some probability ?

hushchyn-mikhail commented 4 years ago

Hi all! Are there any changes?

Sandy4321 commented 4 years ago

Good question

multimeric commented 3 years ago

I note that, as of this month, scipy now includes an implementation of the PDF for the multivariate t-distribution: https://docs.scipy.org/doc/scipy/reference/release.1.6.0.html#scipy-stats-improvements.

Does that make this easy to implement?

multimeric commented 3 years ago

I've also found an R implementation of this algorithm that works on multivariate data, which I think could be used as a meaningful reference. In particular, their "update theta" function is here: <deleted as from GPLv3 licensed code>

hildensia commented 3 years ago

Their code is GPL while this is MIT licence. Make sure you do not port!

Generally, I don't have time to look at this right now, but I'm happy to merge PRs.

On Mon, Jan 25, 2021, at 7:51 AM, Michael Milton wrote:

I've also found an R implementation of this algorithm that works on multivariate data, which I think could be used as a meaningful reference. In particular, their "update theta" function is here: https://github.com/cran/ocp/blob/890dc2e075d5f310f1ace662bf7e25520d88a2c5/R/gaussian.R#L82-L112

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hildensia/bayesian_changepoint_detection/issues/11#issuecomment-766589628, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAVBVEZYG2TP7JRORUQGILS3UIIRANCNFSM4BYKW6NA.

hildensia commented 3 years ago

We're doing some low level optimizations, so it might be hard to transfer those to the multivariate case, especially using a lib version (we basically implemented the distribution manually), but if you're interested go for it.

On Mon, Jan 25, 2021, at 6:45 AM, Michael Milton wrote:

I note that, as of this month, scipy now includes an implementation of the PDF for the multivariate t-distribution: https://docs.scipy.org/doc/scipy/reference/release.1.6.0.html#scipy-stats-improvements.

Does that make this easy to implement?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hildensia/bayesian_changepoint_detection/issues/11#issuecomment-766558091, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAVBVBQECTIOP6XE457Z6LS3UAOXANCNFSM4BYKW6NA.

multimeric commented 3 years ago

I reckon I can give this a shot. Is it okay to reference a book or paper for the maths without breaking the MIT license?

hildensia commented 3 years ago

Papers and math are totally fine.

On Wed, Jan 27, 2021, at 4:19 AM, Michael Milton wrote:

I reckon I can give this a shot. Is it okay to reference a book or paper for the maths without breaking the MIT license?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hildensia/bayesian_changepoint_detection/issues/11#issuecomment-767988585, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAVBVA4VGH4RGSV2WKVEP3S36A3BANCNFSM4BYKW6NA.

multimeric commented 3 years ago

Draft PR in #26. Happy if anyone with a better grasp of the stats runs an eye over my code.

multimeric commented 3 years ago

Can we now close this issue as #26 has been merged?