Coder Social home page Coder Social logo

rookfighter / knn-cpp Goto Github PK

View Code? Open in Web Editor NEW
50.0 50.0 5.0 10.29 MB

A header-only C++ library for k nearest neighbor search with Eigen3.

License: MIT License

CMake 3.51% C++ 95.31% C 1.18%
header-only kd-tree knn knn-search nearest-neighbor-search

knn-cpp's People

Contributors

rookfighter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

knn-cpp's Issues

Compilation errors

I am getting multiple errors on compilation of kdtree_eigen.h.

Some of the variables seem to have not been declared. These are the errors I get:

kdtree_eigen.h:196:42: error: ‘endIdx’ was not declared in this scope
             for(Index i = startIdx; i <= endIdx; ++i)

kdtree_eigen.h:295:33: error: ‘currIndices’ was not declared in this scope
                 return new Node(currIndices);

kdtree_eigen.h:356:40: error: ‘midpoint’ was not declared in this scope
             return new Node(splitaxis, midpoint, leftNode, rightNode);

kdtree_eigen.h:365:16: error: ‘currIndices’ was not declared in this scope
             if(currIndices.size() <= bucketSize_)

compilation on Mac

Hello. I have tried to compile knn-cpp on mac and got the following error:

kdtree_minkowski_search.cpp:8:10: error: 'knncpp.h' file not found with <angled> include; use "quotes" instead
#include <knncpp.h>
         ^~~~~~~~~~
         "knncpp.h"
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:28:13: warning: 'typename' occurs outside of a template [-Wc++11-extensions]
    typedef typename Eigen::MatrixXd::Index Index;
            ^~~~~~~~~
./knncpp.h:64:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix A must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:67:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix B must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:62:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:65:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:104:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix A must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:107:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix B must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:102:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:105:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:156:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix A must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:159:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix B must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:154:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:157:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:196:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix A must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:199:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix B must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:194:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:197:13: error: use of undeclared identifier 'static_assert'
            static_assert(
            ^
./knncpp.h:265:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix A must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
In file included from kdtree_minkowski_search.cpp:8:
./knncpp.h:268:17: error: too many arguments provided to function-like macro invocation
                "distance scalar and input matrix B must have same type");
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:930:13: note: macro 'static_assert' defined here
#    define static_assert(__b, __m) _Static_assert(__b, __m)
            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated

Classification 2 classes and 60 Querypoints

I have 2 classes and I want to see if the 60 points are one of these 2 classes. The problem is that I can’t get much data when I implement this algorithm with more than 1 nearest neighbor, cause I get a lot of -1 output otherwise.

please how can I use this algorithm with 2 classes and 60 points to be classified with k=7 without getting -1 in the output? Please can I iterate in the algorithm and adding points to the classes to be looked for as neighbors or the algorithm do that automatically?

Windows 64-bit build warnings

On Windows/Visual Studio a long int does not size up to 64-bit (contrary to all *NIX flavors), but remains 32-bit. As a result, the typedef for Index (matrix.h:15) causes possible loss of precision warnings. Because (almost) everything of STL is using size_t, I would suggest to move to size_t, or if a signed index is wanted, ssize_t (or any other type that sizes with 32 and 64-bit mode of the compiler).

Unfortunately, Visual Studio does not have a typedef for ssize_t, but has SSIZE_T (uppercase). An alternative is also to use typedef long long int Index (which is platform independent). AFAIK long long never sizes to 128 bit :-)

Thanks.

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.