class_docstr: Unsupervised learner for implementing neighbor searches for Time Series.
  
  Parameters
  ----------
  n_neighbors : int (default: 5)
      Number of nearest neighbors to be considered for the decision.
  
  metric : {'dtw', 'softdtw', 'ctw', 'euclidean', 'sqeuclidean',               'cityblock',  'sax'} (default: 'dtw')
      Metric to be used at the core of the nearest neighbor procedure.
      DTW and SAX are described in more detail in :mod:`tslearn.metrics`.
      When SAX is provided as a metric, the data is expected to be
      normalized such that each time series has zero mean and unit
      variance. Other metrics are described in `scipy.spatial.distance doc
      <https://docs.scipy.org/doc/scipy/reference/spatial.distance.html>`_.
  
  metric_params : dict or None (default: None)
      Dictionary of metric parameters.
      For metrics that accept parallelization of the cross-distance matrix
      computations, `n_jobs` and `verbose` keys passed in `metric_params`
      are overridden by the `n_jobs` and `verbose` arguments.
      For 'sax' metric, these are hyper-parameters to be passed at the 
      creation of the `SymbolicAggregateApproximation` object.
  
  n_jobs : int or None, optional (default=None)
      The number of jobs to run in parallel for cross-distance matrix
      computations.
      Ignored if the cross-distance matrix cannot be computed using
      parallelization.
      ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
      ``-1`` means using all processors. See scikit-learns'
      `Glossary <https://scikit-learn.org/stable/glossary.html#term-n-jobs>`__
      for more details.
  
  Notes
  -----
      The training data are saved to disk if this model is
      serialized and may result in a large model file if the training
      dataset is large.
  
  Examples
  --------
  >>> time_series = to_time_series_dataset([[1, 2, 3, 4],
  ...                                       [3, 3, 2, 0],
  ...                                       [1, 2, 2, 4]])
  >>> knn = KNeighborsTimeSeries(n_neighbors=1).fit(time_series)
  >>> dataset = to_time_series_dataset([[1, 1, 2, 2, 2, 3, 4]])
  >>> dist, ind = knn.kneighbors(dataset, return_distance=True)
  >>> dist
  array([[0.]])
  >>> print(ind)
  [[0]]
  >>> knn2 = KNeighborsTimeSeries(n_neighbors=10,
  ...                             metric="euclidean").fit(time_series)
  >>> print(knn2.kneighbors(return_distance=False))
  [[2 1]
   [2 0]
   [0 1]]
docstr: Fit the model using X as training data
  
  Parameters
  ----------
  X : array-like, shape (n_ts, sz, d)
      Training data.
docstr_tok: ["Fit","the","model","using","X","as","training","data","Parameters","--","--","--","--","--","X",":","array-like",",","shape","(","n_ts",",","sz",",","d",")","Training","data","."]
code: def fit(self, X, y=None):
      """Fit the model using X as training data
  
      Parameters
      ----------
      X : array-like, shape (n_ts, sz, d)
          Training data.
      """
      if self.metric in TSLEARN_VALID_METRICS:
          self._ts_metric = self.metric
          self.metric = "precomputed"
  
      X = check_array(
          X,
          allow_nd=True,
          force_all_finite=(self.metric != "precomputed"),
      )
      X = to_time_series_dataset(X)
      X = check_dims(X)
      if self.metric == "precomputed" and hasattr(self, "_ts_metric"):
          self._ts_fit = X
          self._d = X.shape[2]
          self._X_fit = numpy.zeros(
              (self._ts_fit.shape[0], self._ts_fit.shape[0])
          )
      else:
          self._X_fit, self._d = to_sklearn_dataset(X, return_dim=True)
      super().fit(self._X_fit, y)
      if hasattr(self, "_ts_metric"):
          self.metric = self._ts_metric
      return self
  
imports: import numpy
  from sklearn import neighbors
  from sklearn.neighbors import KNeighborsClassifier, NearestNeighbors, KNeighborsRegressor
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from scipy.spatial.distance import cdist
  from tslearn.metrics import cdist_dtw, cdist_ctw, cdist_soft_dtw, cdist_sax, TSLEARN_VALID_METRICS
  from tslearn.piecewise import SymbolicAggregateApproximation
  from tslearn.utils import to_time_series_dataset, to_sklearn_dataset, check_dims
  from tslearn.bases import BaseModelPackage
label_desc: Use image node_id 4 for calling the KNeighborsTimeSeries obj's underlying member method code with example usage: obj.fit(X, y) and returns: self