pynndescent


Namepynndescent JSON
Version 0.5.13 PyPI version JSON
download
home_pagehttp://github.com/lmcinnes/pynndescent
SummaryNearest Neighbor Descent
upload_time2024-06-17 15:48:32
maintainerLeland McInnes
docs_urlNone
authorLeland McInnes
requires_pythonNone
licenseBSD
keywords nearest neighbor knn ann
VCS
bugtrack_url
requirements joblib numpy scikit-learn scipy numba llvmlite
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: doc/pynndescent_logo.png
  :width: 600
  :align: center
  :alt: PyNNDescent Logo

.. image:: https://dev.azure.com/TutteInstitute/build-pipelines/_apis/build/status%2Flmcinnes.pynndescent?branchName=master
    :target: https://dev.azure.com/TutteInstitute/build-pipelines/_build?definitionId=17
    :alt: Azure Pipelines Build Status
.. image:: https://readthedocs.org/projects/pynndescent/badge/?version=latest
    :target: https://pynndescent.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

===========
PyNNDescent
===========

PyNNDescent is a Python nearest neighbor descent for approximate nearest neighbors.
It provides a python implementation of Nearest Neighbor
Descent for k-neighbor-graph construction and approximate nearest neighbor
search, as per the paper:

Dong, Wei, Charikar Moses, and Kai Li.
*"Efficient k-nearest neighbor graph construction for generic similarity
measures."*
Proceedings of the 20th international conference on World wide web. ACM, 2011.

This library supplements that approach with the use of random projection trees for
initialisation. This can be particularly useful for the metrics that are
amenable to such approaches (euclidean, minkowski, angular, cosine, etc.). Graph
diversification is also performed, pruning the longest edges of any triangles in the
graph.

Currently this library targets relatively high accuracy 
(80%-100% accuracy rate) approximate nearest neighbor searches.

--------------------
Why use PyNNDescent?
--------------------

PyNNDescent provides fast approximate nearest neighbor queries. The
`ann-benchmarks <https://github.com/erikbern/ann-benchmarks>`_ system puts it
solidly in the mix of top performing ANN libraries:

**SIFT-128 Euclidean**

.. image:: https://pynndescent.readthedocs.io/en/latest/_images/sift.png
    :alt: ANN benchmark performance for SIFT 128 dataset

**NYTimes-256 Angular**

.. image:: https://pynndescent.readthedocs.io/en/latest/_images/nytimes.png
    :alt: ANN benchmark performance for NYTimes 256 dataset

While PyNNDescent is among fastest ANN library, it is also both easy to install (pip
and conda installable) with no platform or compilation issues, and is very flexible,
supporting a wide variety of distance metrics by default:

**Minkowski style metrics**

- euclidean
- manhattan
- chebyshev
- minkowski

**Miscellaneous spatial metrics**

- canberra
- braycurtis
- haversine

**Normalized spatial metrics**

- mahalanobis
- wminkowski
- seuclidean

**Angular and correlation metrics**

- cosine
- dot
- correlation
- spearmanr
- tsss
- true_angular

**Probability metrics**

- hellinger
- wasserstein

**Metrics for binary data**

- hamming
- jaccard
- dice
- russelrao
- kulsinski
- rogerstanimoto
- sokalmichener
- sokalsneath
- yule

and also custom user defined distance metrics while still retaining performance.

PyNNDescent also integrates well with Scikit-learn, including providing support
for the KNeighborTransformer as a drop in replacement for algorithms
that make use of nearest neighbor computations.

----------------------
How to use PyNNDescent
----------------------

PyNNDescent aims to have a very simple interface. It is similar to (but more
limited than) KDTrees and BallTrees in ``sklearn``. In practice there are
only two operations -- index construction, and querying an index for nearest
neighbors.

To build a new search index on some training data ``data`` you can do something
like

.. code:: python

    from pynndescent import NNDescent
    index = NNDescent(data)

You can then use the index for searching (and can pickle it to disk if you
wish). To search a pynndescent index for the 15 nearest neighbors of a test data
set ``query_data`` you can do something like

.. code:: python

    index.query(query_data, k=15)

and that is pretty much all there is to it. You can find more details in the
`documentation <https://pynndescent.readthedocs.org>`_.

----------
Installing
----------

PyNNDescent is designed to be easy to install being a pure python module with
relatively light requirements:

* numpy
* scipy
* scikit-learn >= 0.22
* numba >= 0.51

all of which should be pip or conda installable. The easiest way to install should be
via conda:

.. code:: bash

    conda install -c conda-forge pynndescent

or via pip:

.. code:: bash

    pip install pynndescent

To manually install this package:

.. code:: bash

    wget https://github.com/lmcinnes/pynndescent/archive/master.zip
    unzip master.zip
    rm master.zip
    cd pynndescent-master
    python setup.py install

----------------
Help and Support
----------------

This project is still young. The documentation is still growing. In the meantime please
`open an issue <https://github.com/lmcinnes/pynndescent/issues/new>`_
and I will try to provide any help and guidance that I can. Please also check
the docstrings on the code, which provide some descriptions of the parameters.

-------
License
-------

The pynndescent package is 2-clause BSD licensed. Enjoy.

------------
Contributing
------------

Contributions are more than welcome! There are lots of opportunities
for potential projects, so please get in touch if you would like to
help out. Everything from code to notebooks to
examples and documentation are all *equally valuable* so please don't feel
you can't contribute. To contribute please `fork the project <https://github.com/lmcinnes/pynndescent/issues#fork-destination-box>`_ make your changes and
submit a pull request. We will do our best to work through any issues with
you and get your code merged into the main branch.



            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/lmcinnes/pynndescent",
    "name": "pynndescent",
    "maintainer": "Leland McInnes",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "leland.mcinnes@gmail.com",
    "keywords": "nearest neighbor, knn, ANN",
    "author": "Leland McInnes",
    "author_email": "leland.mcinnes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/58/560a4db5eb3794d922fe55804b10326534ded3d971e1933c1eef91193f5e/pynndescent-0.5.13.tar.gz",
    "platform": null,
    "description": ".. image:: doc/pynndescent_logo.png\n  :width: 600\n  :align: center\n  :alt: PyNNDescent Logo\n\n.. image:: https://dev.azure.com/TutteInstitute/build-pipelines/_apis/build/status%2Flmcinnes.pynndescent?branchName=master\n    :target: https://dev.azure.com/TutteInstitute/build-pipelines/_build?definitionId=17\n    :alt: Azure Pipelines Build Status\n.. image:: https://readthedocs.org/projects/pynndescent/badge/?version=latest\n    :target: https://pynndescent.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n===========\nPyNNDescent\n===========\n\nPyNNDescent is a Python nearest neighbor descent for approximate nearest neighbors.\nIt provides a python implementation of Nearest Neighbor\nDescent for k-neighbor-graph construction and approximate nearest neighbor\nsearch, as per the paper:\n\nDong, Wei, Charikar Moses, and Kai Li.\n*\"Efficient k-nearest neighbor graph construction for generic similarity\nmeasures.\"*\nProceedings of the 20th international conference on World wide web. ACM, 2011.\n\nThis library supplements that approach with the use of random projection trees for\ninitialisation. This can be particularly useful for the metrics that are\namenable to such approaches (euclidean, minkowski, angular, cosine, etc.). Graph\ndiversification is also performed, pruning the longest edges of any triangles in the\ngraph.\n\nCurrently this library targets relatively high accuracy \n(80%-100% accuracy rate) approximate nearest neighbor searches.\n\n--------------------\nWhy use PyNNDescent?\n--------------------\n\nPyNNDescent provides fast approximate nearest neighbor queries. The\n`ann-benchmarks <https://github.com/erikbern/ann-benchmarks>`_ system puts it\nsolidly in the mix of top performing ANN libraries:\n\n**SIFT-128 Euclidean**\n\n.. image:: https://pynndescent.readthedocs.io/en/latest/_images/sift.png\n    :alt: ANN benchmark performance for SIFT 128 dataset\n\n**NYTimes-256 Angular**\n\n.. image:: https://pynndescent.readthedocs.io/en/latest/_images/nytimes.png\n    :alt: ANN benchmark performance for NYTimes 256 dataset\n\nWhile PyNNDescent is among fastest ANN library, it is also both easy to install (pip\nand conda installable) with no platform or compilation issues, and is very flexible,\nsupporting a wide variety of distance metrics by default:\n\n**Minkowski style metrics**\n\n- euclidean\n- manhattan\n- chebyshev\n- minkowski\n\n**Miscellaneous spatial metrics**\n\n- canberra\n- braycurtis\n- haversine\n\n**Normalized spatial metrics**\n\n- mahalanobis\n- wminkowski\n- seuclidean\n\n**Angular and correlation metrics**\n\n- cosine\n- dot\n- correlation\n- spearmanr\n- tsss\n- true_angular\n\n**Probability metrics**\n\n- hellinger\n- wasserstein\n\n**Metrics for binary data**\n\n- hamming\n- jaccard\n- dice\n- russelrao\n- kulsinski\n- rogerstanimoto\n- sokalmichener\n- sokalsneath\n- yule\n\nand also custom user defined distance metrics while still retaining performance.\n\nPyNNDescent also integrates well with Scikit-learn, including providing support\nfor the KNeighborTransformer as a drop in replacement for algorithms\nthat make use of nearest neighbor computations.\n\n----------------------\nHow to use PyNNDescent\n----------------------\n\nPyNNDescent aims to have a very simple interface. It is similar to (but more\nlimited than) KDTrees and BallTrees in ``sklearn``. In practice there are\nonly two operations -- index construction, and querying an index for nearest\nneighbors.\n\nTo build a new search index on some training data ``data`` you can do something\nlike\n\n.. code:: python\n\n    from pynndescent import NNDescent\n    index = NNDescent(data)\n\nYou can then use the index for searching (and can pickle it to disk if you\nwish). To search a pynndescent index for the 15 nearest neighbors of a test data\nset ``query_data`` you can do something like\n\n.. code:: python\n\n    index.query(query_data, k=15)\n\nand that is pretty much all there is to it. You can find more details in the\n`documentation <https://pynndescent.readthedocs.org>`_.\n\n----------\nInstalling\n----------\n\nPyNNDescent is designed to be easy to install being a pure python module with\nrelatively light requirements:\n\n* numpy\n* scipy\n* scikit-learn >= 0.22\n* numba >= 0.51\n\nall of which should be pip or conda installable. The easiest way to install should be\nvia conda:\n\n.. code:: bash\n\n    conda install -c conda-forge pynndescent\n\nor via pip:\n\n.. code:: bash\n\n    pip install pynndescent\n\nTo manually install this package:\n\n.. code:: bash\n\n    wget https://github.com/lmcinnes/pynndescent/archive/master.zip\n    unzip master.zip\n    rm master.zip\n    cd pynndescent-master\n    python setup.py install\n\n----------------\nHelp and Support\n----------------\n\nThis project is still young. The documentation is still growing. In the meantime please\n`open an issue <https://github.com/lmcinnes/pynndescent/issues/new>`_\nand I will try to provide any help and guidance that I can. Please also check\nthe docstrings on the code, which provide some descriptions of the parameters.\n\n-------\nLicense\n-------\n\nThe pynndescent package is 2-clause BSD licensed. Enjoy.\n\n------------\nContributing\n------------\n\nContributions are more than welcome! There are lots of opportunities\nfor potential projects, so please get in touch if you would like to\nhelp out. Everything from code to notebooks to\nexamples and documentation are all *equally valuable* so please don't feel\nyou can't contribute. To contribute please `fork the project <https://github.com/lmcinnes/pynndescent/issues#fork-destination-box>`_ make your changes and\nsubmit a pull request. We will do our best to work through any issues with\nyou and get your code merged into the main branch.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Nearest Neighbor Descent",
    "version": "0.5.13",
    "project_urls": {
        "Homepage": "http://github.com/lmcinnes/pynndescent"
    },
    "split_keywords": [
        "nearest neighbor",
        " knn",
        " ann"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d253d23a97e0a2c690d40b165d1062e2c4ccc796be458a1ce59f6ba030434663",
                "md5": "7ee44b64b36ef708d80b1a0e5f4b5bf9",
                "sha256": "69aabb8f394bc631b6ac475a1c7f3994c54adf3f51cd63b2730fefba5771b949"
            },
            "downloads": -1,
            "filename": "pynndescent-0.5.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ee44b64b36ef708d80b1a0e5f4b5bf9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 56850,
            "upload_time": "2024-06-17T15:48:31",
            "upload_time_iso_8601": "2024-06-17T15:48:31.184860Z",
            "url": "https://files.pythonhosted.org/packages/d2/53/d23a97e0a2c690d40b165d1062e2c4ccc796be458a1ce59f6ba030434663/pynndescent-0.5.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e58560a4db5eb3794d922fe55804b10326534ded3d971e1933c1eef91193f5e",
                "md5": "c02cb0aadcb00995502332d98808c6be",
                "sha256": "d74254c0ee0a1eeec84597d5fe89fedcf778593eeabe32c2f97412934a9800fb"
            },
            "downloads": -1,
            "filename": "pynndescent-0.5.13.tar.gz",
            "has_sig": false,
            "md5_digest": "c02cb0aadcb00995502332d98808c6be",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2975955,
            "upload_time": "2024-06-17T15:48:32",
            "upload_time_iso_8601": "2024-06-17T15:48:32.914347Z",
            "url": "https://files.pythonhosted.org/packages/7e/58/560a4db5eb3794d922fe55804b10326534ded3d971e1933c1eef91193f5e/pynndescent-0.5.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-17 15:48:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lmcinnes",
    "github_project": "pynndescent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "appveyor": true,
    "requirements": [
        {
            "name": "joblib",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.17"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    ">=",
                    "0.18"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.0"
                ]
            ]
        },
        {
            "name": "numba",
            "specs": [
                [
                    ">=",
                    "0.51.2"
                ]
            ]
        },
        {
            "name": "llvmlite",
            "specs": [
                [
                    ">=",
                    "0.34"
                ]
            ]
        }
    ],
    "lcname": "pynndescent"
}
        
Elapsed time: 0.30185s