deepcharles / ruptures

ruptures: change point detection in Python
BSD 2-Clause "Simplified" License
1.54k stars 160 forks source link

How to get the best number of the break point? #271

Closed dzheng2333 closed 1 year ago

dzheng2333 commented 1 year ago

model = "l2" # "l1", "rbf", "linear", "normal", "ar",... algo = rpt.Binseg(model=model).fit(data) my_bkps = algo.predict(5)

show results

rpt.show.display(data, my_bkps, figsize=(10, 6)) plt.xticks(range(39),x_ticks,rotation=60) plt.show()

Here is my current code that I have to set the n_brk with specific values. However, for my dataset, I don't know the break point data, so how can I get the best number of the break point?

Many thanks

deepcharles commented 1 year ago

Hi,

Thanks for your interest in ruptures.

When the number of changes is not known, you must use a penalized approach. To understand what it is, you can refer to this article of mine.

In terms of code, this amounts to

my_bkps = algo.predict(pen=penalty_value)

where penalty_value is a positive float that controls how many changes you want (higher values yield less changes). Finding a correct value is really dependant on your situation. I will need more information about your signal to further help you.