Skip to content

Instanciating once a Pelt model and fitting it with different signals yields same result but not when instanciating the model for each fit #372

Description

@Ayoub-Aarab

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions