Closed 943fansi closed 1 year ago
Hi @943fansi ,
Thx for your interest in ruptures
!
Could you share with us the whole code snippet. Indeed, here we do not see how you created cp_detector
. Please find some documentation on how to use Dynamic Programming search method that you seem to use.
has no attribute 'signal'
also tells you that maybe you did not perform the .fit(signal)
before calling predict()
.
Hope it helps !
Hi @943fansi ,
Thx for your interest in
ruptures
!Could you share with us the whole code snippet. Indeed, here we do not see how you created
cp_detector
. Please find some documentation on how to use Dynamic Programming search method that you seem to use.has no attribute 'signal'
also tells you that maybe you did not perform the.fit(signal)
before callingpredict()
.Hope it helps !
I uninstalled 1.1.7
version, and installed version 1.0.3
ruptures. Then it works well.
# define and fit costum cost object
custom_cost = kernel_hyper(dct_config['kernel'], dct_config['bandwidth']).fit(ar_signal)
# define and fit search method
cp_detector = rpt.Dynp(custom_cost=custom_cost, jump=1).fit(ar_signal)
where
dct_config = dict({ # data intake settings
'load_sample_data': True, # True, False
'signal_id': 1, # 0,1,2,3,4,5,6,7,8,9,10
# kernel configuration for cost function
'kernel': 'laplace', # 'gaussian', 'linear', 'laplace'
'bandwidth': 'sig_std_batch_max', # 'median', 'sig_std',
# 'sig_std_batch_max'
# penalty heuristic configuration
'pen_heur': 'cost', # 'cost', 'slope'
'alpha': 150, # opt range cost_heur ~75-150 / slope_heur ~4-12
'n_cp_max': 10, # maximum number of cps considered
'D_max': 10, # max number of segments considered =<n_cp_max
`'D_min': 6}) # min number of segments for slope heuristics``
Thx !
Btw, I forgot to paste the link to the documentation about Dynamic Programming : https://centre-borelli.github.io/ruptures-docs/user-guide/detection/dynp/
Now, about your code, in the implementation of the .fit()
method of your custom cost kernel_hyper
, do you have the instruction self.signal = signal
(see here for examples ) ?
Moreover, you do not have to call custom_cost = kernel_hyper(dct_config['kernel'], dct_config['bandwidth']).fit(ar_signal)
because when you call cp_detector = rpt.Dynp(custom_cost=custom_cost, jump=1).fit(ar_signal)
, then the .fit()
call is forwarded to the cost class (see here in ruptures
codebase).
Thx !
Btw, I forgot to paste the link to the documentation about Dynamic Programming : https://centre-borelli.github.io/ruptures-docs/user-guide/detection/dynp/
Now, about your code, in the implementation of the method of your custom cost , do you have the instruction (see here for examples ) ?
.fit()``kernel_hyper ``self.signal = signal
Moreover, you do not have to call because when you call , then the call is forwarded to the cost class (see here in codebase).
custom_cost = kernel_hyper(dct_config['kernel'], dct_config['bandwidth']).fit(ar_signal)``cp_detector = rpt.Dynp(custom_cost=custom_cost, jump=1).fit(ar_signal)``.fit()``ruptures
Thank you very much for your explanation. I am studying anomaly monitoring of time series. An application paper I found uses change point detection to make exception judgments, and its open-source code uses ruptures
package. I'm a novice at change point detection, so I sincerely thank you again.
In that case, @deepcharles 's article might be a good start : http://www.laurentoudre.fr/publis/TOG-SP-19.pdf
Basically, ruptures
started as an implementation of this article !
Closing for now. Feel free to reopen.
import ruptures as rpt
print(rpt.__version__)
1.1.7
lst_cp_det = list(np.sort(cp_detector.predict(n_bkps=n_cp)))
ruptures\detection\dynp.py", line 132, in predict n_samples=self.cost.signal.shape[0],
AttributeError: 'kernel_hyper' object has no attribute 'signal'