.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/annoy/plot_simple_script.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via JupyterLite or Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_annoy_plot_simple_script.py: annoy with examples ================================== An example showing the :py:func:`~scikitplot.cexternals.annoy` function. .. GENERATED FROM PYTHON SOURCE LINES 7-11 .. code-block:: Python :lineno-start: 8 # Authors: Spotify AB # SPDX-License-Identifier: Apache-2.0 .. GENERATED FROM PYTHON SOURCE LINES 12-13 from annoy import AnnoyIndex .. GENERATED FROM PYTHON SOURCE LINES 13-24 .. code-block:: Python :lineno-start: 13 from scikitplot.cexternals.annoy import AnnoyIndex a = AnnoyIndex(3, 'angular') a.add_item(0, [1, 0, 0]) a.add_item(1, [0, 1, 0]) a.add_item(2, [0, 0, 1]) a.build(-1) print(a.get_nns_by_item(0, 100)) print(a.get_nns_by_vector([1.0, 0.5, 0.5], 100)) .. rst-class:: sphx-glr-script-out .. code-block:: none [0, 1, 2] [0, 1, 2] .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. tags:: model-type: classification model-workflow: impute plot-type: bar level: beginner purpose: showcase .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.003 seconds) .. _sphx_glr_download_auto_examples_annoy_plot_simple_script.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-plots/scikit-plots/main?urlpath=lab/tree/notebooks/auto_examples/annoy/plot_simple_script.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/annoy/plot_simple_script.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_simple_script.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_simple_script.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_simple_script.zip ` .. include:: plot_simple_script.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_