Giter Site home page Giter Site logo

pydci's Introduction

Dynamic Continuous Indexing (in Python)

This is a Python only implementation of the Dynamic Continuous Indexing (DCI) algorithm proposed by Jitendra Malik and Ke Li for quickly solving the k-nearest neighbors problem. See also Ke Li's original implementation in C with Python and TensorFlow bindings.

Installation

  • To just use pydci: pip install .
  • If you'd like to modify it: pip install --editable .

Tests

  • Dependencies: pip install -r requirements_test.txt
  • Running: pytest pydci/test_pydci.py

Usage

  • Instantiate a DCI index with dci = DCI(dim, num_simple, num_composite)
    • dim: Dimension of data points
    • num_simple: Number of simple indices (i.e., projection directions) to contain in each composite index; can be about half the dimension of data points
    • num_composite: Number of groups of simple indices; can be small, e.g., 3
  • Add data set with dci.add(X); can be called multiple times to add more data
    • X: Dataset with each point as a row
  • Search for k-nearest neighbors of query point with dci.query(q, k, max_retrieve_const, max_composite_visit_const)
    • q: Query point
    • k: Number of nearest neighbors
    • max_retrieve_const: Determines computational extent of query step; higher takes longer but is more accurate, values between 1-10 work well
    • max_composite_visit_const: Determines computational extent of query step; higher takes longer but is more accurate, values between 1-10 work well

See pydci/test_pydci.py for a starter example.

About

Written by Craig Gross ([email protected]) and Cullen Haselby ([email protected]) for a project in Michigan State University's MSIM course in spring 2022.

Why reimplement?

An important property of DCI is that it supports fast (sublinear) insertions to the underlying data structure. This functionality is not available in the original implementation. Though this pure Python implementation will be slower than the interface to the C code, we are only interested in understanding the overall scaling of DCI when applied to solve nearest neighbor problems on streaming datasets.

pydci's People

Contributors

cgross95 avatar cahaselby avatar

Stargazers

 avatar Gurumurthi V Ramanan avatar Dingyuan Wang avatar

Watchers

 avatar

pydci's Issues

Remove scikit-learn dependency

The scikit-learn dependency is extremely heavy for just doing a fast brute force nearest neighbors search. Ideally, a lightweight C-based brute force search implementation should be used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.