class_docstr: k-nearest neighbors classifier.
  
  Parameters
  ----------
  n_neighbors : int, optional (default = 1)
      Number of neighbors to use.
  
  weights : str or callable, optional (default = 'uniform')
      weight function used in prediction.  Possible values:
  
      - 'uniform' : uniform weights.  All points in each neighborhood
        are weighted equally.
      - 'distance' : weight points by the inverse of their distance.
        in this case, closer neighbors of a query point will have a
        greater influence than neighbors which are further away.
      - [callable] : a user-defined function which accepts an
        array of distances, and returns an array of the same shape
        containing the weights.
  
  algorithm : {'auto', 'ball_tree', 'kd_tree', 'brute'}, optional
      Algorithm used to compute the nearest neighbors. Ignored ff ``metric``
      is either 'dtw', 'dtw_sakoechiba', 'dtw_itakura', 'dtw_multiscale',
      'dtw_fast' or 'boss' ('brute' will be used).
  
      Note: fitting on sparse input will override the setting of
      this parameter, using brute force.
  
  leaf_size : int, optional (default = 30)
      Leaf size passed to BallTree or KDTree.  This can affect the
      speed of the construction and query, as well as the memory
      required to store the tree.  The optimal value depends on the
      nature of the problem.
  
  metric : string or DistanceMetric object (default = 'minkowski')
      The distance metric to use for the tree.  The default metric is
      minkowski, and with p=2 is equivalent to the standard Euclidean
      metric. See the documentation of the DistanceMetric class from
      scikit-learn for a list of available metrics.
      For Dynamic Time Warping, the available metrics are 'dtw',
      'dtw_sakoechiba', 'dtw_itakura', 'dtw_multiscale' and 'dtw_fast'.
      For BOSS metric, one can use 'boss'.
  
  p : integer, optional (default = 2)
      Power parameter for the Minkowski metric. When p = 1, this is
      equivalent to using manhattan_distance (l1), and euclidean_distance
      (l2) for p = 2. For arbitrary p, minkowski_distance (l_p) is used.
  
  metric_params : dict, optional (default = None)
      Additional keyword arguments for the metric function.
  
  n_jobs : int, optional (default = 1)
      The number of parallel jobs to run for neighbors search.
      If ``n_jobs=-1``, then the number of jobs is set to the number of CPU
      cores. Doesn't affect :meth:`fit` method.
  
  Attributes
  ----------
  classes_ : array, shape = (n_classes,)
      An array of class labels known to the classifier.
  
  Examples
  --------
  >>> from pyts.classification import KNeighborsClassifier
  >>> from pyts.datasets import load_gunpoint
  >>> X_train, X_test, y_train, y_test = load_gunpoint(return_X_y=True)
  >>> clf = KNeighborsClassifier()
  >>> clf.fit(X_train, y_train)
  KNeighborsClassifier(...)
  >>> clf.score(X_test, y_test)
  0.91...
class_docstr_tok: ["k-nearest","neighbors","classifier",".","Parameters","--","--","--","--","--","n_neighbors",":","int",",","optional","(","default","=","1",")","Number","of","neighbors","to","use",".","weights",":","str","or","callable",",","optional","(","default","=","'uniform","'",")","weight","function","used","in","prediction",".","Possible","values",":","-","'uniform","'",":","uniform","weights",".","All","points","in","each","neighborhood","are","weighted","equally",".","-","'distance","'",":","weight","points","by","the","inverse","of","their","distance",".","in","this","case",",","closer","neighbors","of","a","query","point","will","have","a","greater","influence","than","neighbors","which","are","further","away",".","-","[","callable","]",":","a","user-defined","function","which","accepts","an","array","of","distances",",","and","returns","an","array","of","the","same","shape","containing","the","weights",".","algorithm",":","{","'auto","'",",","'ball_tree","'",",","'kd_tree","'",",","'brute","'","}",",","optional","Algorithm","used","to","compute","the","nearest","neighbors",".","Ignored","ff","``","metric","``","is","either","'dtw","'",",","'dtw_sakoechiba","'",",","'dtw_itakura","'",",","'dtw_multiscale","'",",","'dtw_fast","'","or","'boss","'","(","'brute","'","will","be","used",")",".","Note",":","fitting","on","sparse","input","will","override","the","setting","of","this","parameter",",","using","brute","force",".","leaf_size",":","int",",","optional","(","default","=","30",")","Leaf","size","passed","to","BallTree","or","KDTree",".","This","can","affect","the","speed","of","the","construction","and","query",",","as","well","as","the","memory","required","to","store","the","tree",".","The","optimal","value","depends","on","the","nature","of","the","problem",".","metric",":","string","or","DistanceMetric","object","(","default","=","'minkowski","'",")","The","distance","metric","to","use","for","the","tree",".","The","default","metric","is","minkowski",",","and","with","p=2","is","equivalent","to","the","standard","Euclidean","metric",".","See","the","documentation","of","the","DistanceMetric","class","from","scikit-learn","for","a","list","of","available","metrics",".","For","Dynamic","Time","Warping",",","the","available","metrics","are","'dtw","'",",","'dtw_sakoechiba","'",",","'dtw_itakura","'",",","'dtw_multiscale","'","and","'dtw_fast","'",".","For","BOSS","metric",",","one","can","use","'boss","'",".","p",":","integer",",","optional","(","default","=","2",")","Power","parameter","for","the","Minkowski","metric",".","When","p","=","1",",","this","is","equivalent","to","using","manhattan_distance","(","l1",")",",","and","euclidean_distance","(","l2",")","for","p","=","2",".","For","arbitrary","p",",","minkowski_distance","(","l_p",")","is","used",".","metric_params",":","dict",",","optional","(","default","=","None",")","Additional","keyword","arguments","for","the","metric","function",".","n_jobs",":","int",",","optional","(","default","=","1",")","The","number","of","parallel","jobs","to","run","for","neighbors","search",".","If","``","n_jobs=-1","``",",","then","the","number","of","jobs","is","set","to","the","number","of","CPU","cores",".","Does","n't","affect",":","meth",":","`","fit","`","method",".","Attributes","--","--","--","--","--","classes_",":","array",",","shape","=","(","n_classes",",",")","An","array","of","class","labels","known","to","the","classifier",".","Examples","--","--","--","--",">",">",">","from","pyts.classification","import","KNeighborsClassifier",">",">",">","from","pyts.datasets","import","load_gunpoint",">",">",">","X_train",",","X_test",",","y_train",",","y_test","=","load_gunpoint","(","return_X_y=True",")",">",">",">","clf","=","KNeighborsClassifier","(",")",">",">",">","clf.fit","(","X_train",",","y_train",")","KNeighborsClassifier","(","...",")",">",">",">","clf.score","(","X_test",",","y_test",")","0.91","..."]
code: def __init__(
      self,
      n_neighbors=1,
      weights="uniform",
      algorithm="auto",
      leaf_size=30,
      p=2,
      metric="minkowski",
      metric_params=None,
      n_jobs=1,
      **kwargs,
  ):
      self.n_neighbors = n_neighbors
      self.weights = weights
      self.algorithm = algorithm
      self.leaf_size = leaf_size
      self.p = p
      self.metric = metric
      self.metric_params = metric_params
      self.n_jobs = n_jobs
      self.kwargs = kwargs
  
file_path: pyts/pyts/classification/knn.py
imports: from sklearn.base import BaseEstimator
  from sklearn.neighbors import KNeighborsClassifier
  from sklearn.preprocessing import LabelEncoder
  from sklearn.utils.validation import check_X_y, check_is_fitted
  from ..base import UnivariateClassifierMixin
  from ..metrics import boss, dtw, sakoe_chiba_band, itakura_parallelogram
  from ..metrics.dtw import _dtw_classic, _dtw_region, _dtw_fast, _dtw_multiscale
label_desc: Use image node_id 1 to create a new KNeighborsClassifier object from inherited base classes: BaseEstimator, UnivariateClassifierMixin with example: obj = KNeighborsClassifier(n_neighbors, weights, algorithm, leaf_size, p, metric, metric_params, n_jobs)