

.. _sphx_glr_auto_examples_neighbors:

.. _neighbors_examples:

Nearest Neighbors
-----------------------

Examples concerning the :mod:`sklearn.neighbors` module.



.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example presents how to chain KNeighborsTransformer and TSNE in a pipeline. It also shows ...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_approximate_nearest_neighbors_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_approximate_nearest_neighbors.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Approximate nearest neighbors in TSNE</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This examples demonstrates how to precompute the k nearest neighbors before using them in KNeig...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_caching_nearest_neighbors_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_caching_nearest_neighbors.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Caching nearest neighbors</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="An example comparing nearest neighbors classification with and without Neighborhood Components ...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_nca_classification_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_nca_classification.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Comparing Nearest Neighbors with and without Neighborhood Components Analysis</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Sample usage of Neighborhood Components Analysis for dimensionality reduction.">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_nca_dim_reduction_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_nca_dim_reduction.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Dimensionality Reduction with Neighborhood Components Analysis</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example does not perform any learning over the data (see sphx_glr_auto_examples_applicatio...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_species_kde_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_species_kde.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Kernel Density Estimate of Species Distributions</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example shows how kernel density estimation (KDE), a powerful non-parametric density estim...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_digits_kde_sampling_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_digits_kde_sampling.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Kernel Density Estimation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Sample usage of Nearest Centroid classification. It will plot the decision boundaries for each ...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_nearest_centroid_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_nearest_centroid.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Nearest Centroid Classification</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example shows how to use KNeighborsClassifier. We train such a classifier on the iris data...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_classification_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_classification.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Nearest Neighbors Classification</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate the resolution of a regression problem using a k-Nearest Neighbor and the interpola...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_regression_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_regression.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Nearest Neighbors regression</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example illustrates a learned distance metric that maximizes the nearest neighbors classif...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_nca_illustration_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_nca_illustration.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Neighborhood Components Analysis Illustration</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The Local Outlier Factor (LOF) algorithm is an unsupervised anomaly detection method which comp...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_lof_novelty_detection_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_lof_novelty_detection.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Novelty detection with Local Outlier Factor (LOF)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The Local Outlier Factor (LOF) algorithm is an unsupervised anomaly detection method which comp...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_lof_outlier_detection_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_lof_outlier_detection.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Outlier detection with Local Outlier Factor (LOF)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The first plot shows one of the problems with using histograms to visualize the density of poin...">

.. only:: html

  .. image:: /auto_examples/neighbors/images/thumb/sphx_glr_plot_kde_1d_thumb.png
    :alt:

  :ref:`sphx_glr_auto_examples_neighbors_plot_kde_1d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Simple 1D Kernel Density Estimation</div>
    </div>


.. raw:: html

    </div>


.. toctree::
   :hidden:

   /auto_examples/neighbors/approximate_nearest_neighbors
   /auto_examples/neighbors/plot_caching_nearest_neighbors
   /auto_examples/neighbors/plot_nca_classification
   /auto_examples/neighbors/plot_nca_dim_reduction
   /auto_examples/neighbors/plot_species_kde
   /auto_examples/neighbors/plot_digits_kde_sampling
   /auto_examples/neighbors/plot_nearest_centroid
   /auto_examples/neighbors/plot_classification
   /auto_examples/neighbors/plot_regression
   /auto_examples/neighbors/plot_nca_illustration
   /auto_examples/neighbors/plot_lof_novelty_detection
   /auto_examples/neighbors/plot_lof_outlier_detection
   /auto_examples/neighbors/plot_kde_1d

