tslearn icon indicating copy to clipboard operation
tslearn copied to clipboard

Unexpected behavior in 3D matrices

Open delacylab opened this issue 1 year ago • 0 comments

Describe the bug Tslearn supports unequal time series by filling nans at the end. But this does not seem to work with 3D matrices where the dimension is greater than 1 as shown below.

To Reproduce X, y = random_walk_blobs(n_ts_per_blob=10, sz=3, d=2, n_blobs=2) #(20, 3, 2) shape X[19,2,1] = np.nan #Change last row, last timestep, last dimension to nan for row 19 clf = tslearn.svm.TimeSeriesSVC(C=1.0, gamma="auto", kernel="gak") clf.fit(X,y)

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

Expected behavior Nans are allowed at the end of matrices throughout tslearn examples and are used to fill unequal timeseries, so I am puzzled why this does not work.

Environment (please complete the following information):

  • OS: Ubuntu 20.04
  • tslearn version 0.5.3.2

Additional context Experimenting has shown that I can only avoid the nan error if the row's entire timestep for all dimensions is nan like with: X[19,2,:] = np.nan That works. So it appears that for each row, a timestep's features have to all be nan or all be a real number where it seems like that shouldn't be the case.

delacylab avatar Apr 25 '23 21:04 delacylab