-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the bug
When using ShapeDTW with KNeighborsTimeSeriesClassifier, as ShapeDTW produces a multivariate time series from a univariate one, when its converted to an array it produces a 3D array. When I set the algorithm flag in KNeighborsTimeSeriesClassifier to 'brute' it works absolutely fine. However, when I set the algorithm flag to 'ball_tree' or 'kd_tree' I get errors. For ShapeDTW, the 3D output is absolutely necessary so I guess it would be good if 'ball_tree' and 'kd_tree' work with a 3D input.
To Reproduce
X = multivariateTimeSeriesData()
y = classLabels()
knn = KNeighborsTimeSeriesClassifier(algorithm='brute')
knn.fit(X)
knn.predict(X,y) # Works fine.
knn = KNeighborsTimeSeriesClassifier(algorithm='kd_tree')
knn.fit(X)
knn.predict(X,y) # Throws - ValueError: kd_tree does not support callable metric '<built-in function dtw_distance>'Function call overhead will resultin very poor performance..
knn = KNeighborsTimeSeriesClassifier(algorithm='ball_tree')
knn.fit(X)
knn.predict(X,y) # Throws - ValueError: Buffer has wrong number of dimensions (expected 2, got 3)Expected behavior
KNeighboursTimeSeriesClassifier supports 3D time series data.
Additional context
To get ShapeDTW working properly, I inserted at lines 184 and 272 - X = nested_to_3d_numpy(X). This was necessary so that
it converted the data into the correct form for ShapeDTW. 'brute' works even with this line, but 'kd_tree' and 'ball_tree' do not.
Versions
Details
Windows-10-10.0.18362-SP0Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
NumPy 1.18.1
SciPy 1.4.1
Pandas 1.0.3
sktime 0.4.0