Skip to content

[BUG] TypeError from KNeighborsTimeSeriesClassifier #608

@Hephaest

Description

@Hephaest

Describe the bug

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-25-a54f834dd466> in <module>
      2 
      3 knn = KNeighborsTimeSeriesClassifier(n_neighbors=1, metric="dtw")
----> 4 knn.fit(X_train, y_train)
      5 knn.score(X_test, y_test)
      6 

~\Desktop\sktime\sktime\classification\distance_based\_time_series_neighbors.py in fit(self, X, y)
    250             check_array.__code__ = _check_array_ts.__code__
    251 
--> 252         fx = self._fit(X, self._y)
    253 
    254         if hasattr(check_array, "__wrapped__"):

TypeError: _fit() takes 2 positional arguments but 3 were given

To Reproduce

from sktime.classification.distance_based import KNeighborsTimeSeriesClassifier

knn = KNeighborsTimeSeriesClassifier(n_neighbors=1, metric="dtw")
knn.fit(X_train, y_train)
knn.score(X_test, y_test)

Expected behavior

Generate the result: 0.55

Additional context

This problem occurs because that NeighborsBase._fit() only accept 1 positional argument (only X).

Versions

Details

System:
python: 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)]
executable: c:\users\hephaest\appdata\local\programs\python\python38\python.exe
machine: Windows-10-10.0.19041-SP0

Python dependencies:
pip: 20.3.3
setuptools: 49.2.1
sklearn: 0.23.2
sktime: 0.5.1
statsmodels: 0.12.1
numpy: 1.19.3
scipy: 1.4.1
Cython: 0.29.21
pandas: 1.1.2
matplotlib: 3.3.2
joblib: 0.17.0
numba: 0.52.0
pmdarima: None
tsfresh: 0.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions