The title says much of it.
If we instanciate the model once and then use that instance to fit different signals, the result of the prediction will remain the one for the first fit.
However, when instanciating the model at each time (for each different signal then) we want to fit a signal, we get a different result for each signal.
This behaviour is weird IMO.
Sample code :
series = np.array(data["historical_data"]["series"])
dates = pd.to_datetime(data["historical_data"]["dates"])
breaks = []
ruptures_model =rpt.Pelt(model="rbf")
for step in range(2, len(series) + 1):
# ruptures_model =rpt.Pelt(model="rbf") # Versus
ruptures_model.fit(series[:step])
new_breaks = ruptures_model.predict(pen=1)
for b in new_breaks: # breaks give values of index-like + 1
if b == step: # It always return a break of value the length of the series ...
new_breaks.remove(b)
breaks = list(set(breaks + new_breaks))
The title says much of it.
If we instanciate the model once and then use that instance to fit different signals, the result of the prediction will remain the one for the first fit.
However, when instanciating the model at each time (for each different signal then) we want to fit a signal, we get a different result for each signal.
This behaviour is weird IMO.
Sample code :
series = np.array(data["historical_data"]["series"])
dates = pd.to_datetime(data["historical_data"]["dates"])
breaks = []
ruptures_model =rpt.Pelt(model="rbf")
for step in range(2, len(series) + 1):
# ruptures_model =rpt.Pelt(model="rbf") # Versus
ruptures_model.fit(series[:step])
new_breaks = ruptures_model.predict(pen=1)