Repository: sktime/sktime

Issue:
[BUG] TypeError from KNeighborsTimeSeriesClassifier
**Describe the bug**
<!--
A clear and concise description of what the bug is.
-->
```Python

---------------------------------------------------------------------------

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**
<!--
Add a Minimal, Complete, and Verifiable example (for more details, see e.g. https://stackoverflow.com/help/mcve

If the code is too long, feel free to put it in a public gist and link it in the issue: https://gist.github.com
-->

```python

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**
<!--
A clear and concise description of what you expected to happen.
-->
Generate the result: `0.55`

**Additional context**
<!--
Add any other context about the problem here.
-->
This problem occurs because that `NeighborsBase._fit()` only accept 1 positional argument (only X).

**Versions**
<details>

<!--
Please run the following code snippet and paste the output here:
 
from sktime import show_versions; show_versions()
-->
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
</details>
<!-- Thanks for contributing! -->


Discussion:

Resolving patch:
diff --git a/sktime/classification/distance_based/_time_series_neighbors.py b/sktime/classification/distance_based/_time_series_neighbors.py
--- a/sktime/classification/distance_based/_time_series_neighbors.py
+++ b/sktime/classification/distance_based/_time_series_neighbors.py
@@ -188,8 +188,6 @@ def fit(self, X, y):
         X, y = check_X_y(X, y, enforce_univariate=False, coerce_to_numpy=True)
         y = np.asarray(y)
         check_classification_targets(y)
-
-        # print(X)
         # if internal cv is desired, the relevant flag forces a grid search
         # to evaluate the possible values,
         # find the best, and then set this classifier's params to match
@@ -236,8 +234,9 @@ def fit(self, X, y):
         else:
             temp = check_array.__code__
             check_array.__code__ = _check_array_ts.__code__
-
-        fx = self._fit(X, self._y)
+        #  this not fx = self._fit(X, self_y) in order to maintain backward
+        # compatibility with scikit learn 0.23, where _fit does not take an arg y
+        fx = self._fit(X)
 
         if hasattr(check_array, "__wrapped__"):
             check_array.__wrapped__.__code__ = temp
@@ -247,6 +246,13 @@ def fit(self, X, y):
         self._is_fitted = True
         return fx
 
+    def _more_tags(self):
+        """Removes the need to pass y with _fit
+        Overrides the scikit learn (>0.23) base class setting where 'requires_y' is true
+        so we can call fx = self._fit(X) and maintain backward compatibility.
+        """
+        return {"requires_y": False}
+
     def kneighbors(self, X, n_neighbors=None, return_distance=True):
         """Finds the K-neighbors of a point.
         Returns indices of and distances to the neighbors of each point.


Test patch: