Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngt

python NGT

  • 2.1.6
  • PyPI
  • Socket score

Maintainers
1

python NGT

日本語

Install

Python binding with pybind11 (ngtpy) is installed as follows.

pip3 install ngt

You can install the python bindings from source code. You MUST install the NGT library according to the README before installing the python bindings as follows.

pip3 install pybind11
pip3 install numpy
cd NGT_ROOT/python
python3 setup.py sdist
pip3 install dist/ngt-x.x.x.tar.gz

Please note that the search speed of the ngtpy packages from PyPI is slower than that of the ngtpy that is built on your computer so that the package can be run on older CPUs.

Documents

ngtpy (pybind11) reference

Simple samples

ngtpy (pybind11)

ngtpy(pybind11) can reduce the processing times than ngt(ctypes). It is more effective especially for the short search time.

  import ngtpy
  import random


  dim = 10
  nb = 100
  vectors = [[random.random() for _ in range(dim)] for _ in range(nb)]
  query = vectors[0]
  
  ngtpy.create(b"tmp", dim)
  index = ngtpy.Index(b"tmp")
  index.batch_insert(vectors)
  index.save()

  results = index.search(query, 3)
  for i, (id, distance) in enumerate(results) :
      print(str(i) + ": " + str(id) + ", " + str(distance))
      object = index.get_object(id)
      print(object)

See also sample.py.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc