Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in TimeSeriesKMeans using metric 'softdtw' #38

Closed
nikhilRP opened this issue May 11, 2018 · 4 comments
Closed

Bug in TimeSeriesKMeans using metric 'softdtw' #38

nikhilRP opened this issue May 11, 2018 · 4 comments
Labels

Comments

@nikhilRP
Copy link

Hello @rtavenar ,

I was trying out the TimeSeriesKMeans model with variable length time series.
Unfortunately the model seems to fail using "softdtw" as a metric.

Code I tried out.

import numpy
import random

from tslearn.clustering import TimeSeriesKMeans

seed = 0
numpy.random.seed(seed)

ts = list()

# random time series of variable length
ts.append(random.sample(range(1, 1000), 100))
ts.append(random.sample(range(1, 1000), 99))
ts.append(random.sample(range(1, 1000), 98))

# Soft-DTW-k-means
print("Soft-DTW k-means")
sdtw_km = TimeSeriesKMeans(
    n_clusters=2, metric="softdtw", verbose=True, random_state=seed)
y_pred = sdtw_km.fit_predict(ts)

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

Any help would be appreciated, thanks.

@rtavenar
Copy link
Member

Hi @nikhilRP , and thanks for this very precise bug report.

I'll try to investigate on this as soon as I can. This is definitely a bug, but I have no idea at the moment how difficult it would be to solve it.
I'll let you know.

rtavenar added a commit that referenced this issue May 14, 2018
@rtavenar
Copy link
Member

rtavenar commented May 14, 2018

@nikhilRP

I have just pushed a version that fixes the issue on my side (v0.1.16.3 on PyPI). Coud you confirm that it's OK for you? If so, I'll add a doctest to ensure that we do not have the same bug in later versions.

Best,
Romain

@rtavenar rtavenar added the bug label May 14, 2018
@nikhilRP
Copy link
Author

Thanks for taking time and fixing it. I did test the fix and it works fine, very much appreciated.

@rtavenar
Copy link
Member

Great! By the way, I guess this fix is a step forward regarding Issue #16 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants