deepcharles / ruptures

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

Failure with new version of ruptures (1.1.4) #195

Closed DrewScoggins closed 3 years ago

DrewScoggins commented 3 years ago

When I do a pip install of the latest ruptures package, I got the following exception

Traceback (most recent call last):
  File "D:\git\perfcommand\src\perfcommandcore\bin\Debug\netcoreapp3.1\bocpd.py", line 14, in <module>
    results = algo.predict(pen=4*np.log(len(points)))
  File "C:\Users\anscoggi\AppData\Local\Programs\Python\Python39\lib\site-packages\ruptures\detection\pelt.py", line 125, in predict
    n_samples=self.cost.signal.shape[0],
AttributeError: 'CostMl' object has no attribute 'signal'

The versions of all of the libraries I have installed are:

Successfully installed numpy-1.21.2 ruptures-1.1.4 scipy-1.7.

Finally, the code that I am attempting to run is:

import numpy as np
import ruptures as rpt
import sys

data = open(sys.argv[1], "r").read()
points = data.split(',')

for i in range(0, len(points)):
    points[i] = float (points[i])

points = np.concatenate([points])

algo = rpt.Pelt(model="mahalanobis", jump=1, min_size=3).fit(points)
results = algo.predict(pen=4*np.log(len(points)))
deepcharles commented 3 years ago

Thanks for your interest in ruptures.

Normally this issue should have been resolved in #173. I cannot replicate it with version 1.1.4.

Can you tell me the output of the following lines ?

import ruptures as rpt
print(rpt.__version__)
oboulant commented 3 years ago

Hello @DrewScoggins ,

Thanks for your interest in ruptures !

I can replicate and get the error with :

I can also confirm that this issue is solved by https://github.com/deepcharles/ruptures/pull/173

If you need an immediate solution, we can perform an install from the source. Indeed, by doing so, I confirm I do not have the error.

Otherwise, this fix will be integrated into the next ruptures release :)

DrewScoggins commented 3 years ago

Sorry, I missed the current issue. I worked around this by just going back to 1.1.3, that will work just fine until the next release.