tslearn-team / tslearn

The machine learning toolkit for time series analysis in Python
https://tslearn.readthedocs.io
BSD 2-Clause "Simplified" License
2.92k stars 342 forks source link

Regression not working for arrays longer than 405 elements (overflow in matrix) #450

Open JanNalivaika opened 1 year ago

JanNalivaika commented 1 year ago

I am trying to do some regression on time series on different length. But I'm having issues with lengths longer than 406 elements

The error message is: ValueError: Input X contains NaN. SVR does not accept missing values encoded as NaN natively.

Function: "njit_gak" has an overflow issue

To Reproduce #################################################################### import numpy as np from tslearn.utils import to_time_series_dataset from tslearn.svm import TimeSeriesSVR from numpy import random from tslearn.preprocessing import TimeSeriesScalerMinMax

def fun(): x = np.arange(500) # Length of array here y = x*2random.rand()/2000+ np.sin(x) + np.cos(x)

return abs(y)

input = [] output = [] for reps in range(3):

y = fun()
input.append(list(y))
output.append(np.sqrt(np.min(y)))

X = to_time_series_dataset(input) X1 = TimeSeriesScalerMinMax().fit_transform(X)

clf = TimeSeriesSVR(C=1.0, kernel="gak")

y_reg = output clf.fit(X1, y_reg) ################################################################### Does anyone have the same issue?

Thank you very much!

NimaSarajpoor commented 1 year ago

@JanNalivaika Two notes: