GithubHelp home page GithubHelp logo

ChiSquareDistance problem about flann HOT 5 CLOSED

Marzounette avatar Marzounette commented on August 18, 2024
ChiSquareDistance problem

from flann.

Comments (5)

mariusmuja avatar mariusmuja commented on August 18, 2024

Since you mention you are using the flann_set_distance_type() function, I assume you are using the C bindings, is this correct? What version of FLANN are you using (1.7.1, trunk)? Can you include a small code snippet of your code?

from flann.

Marzounette avatar Marzounette commented on August 18, 2024

Thanks for your response Marius.

Yes, i use the C bindings with FLANN 1.7.1.
Here is a snippet of my code :
//
FLANNParameters flann_params;
flann_params.checks = FLANN_CHECKS_UNLIMITED;
flann_params.eps = 0.0;
flann_params.trees = 1;
flann_params.algorithm = FLANN_INDEX_KDTREE;
flann_set_distance_type( FLANN_DIST_CHI_SQUARE, 0);

flann_index_t index_ptr;
flann_find_nearest_neighbors_index( index_ptr, testset, tcount, result, dists, nn, flann_params);
//

I'm looking for the nn exact nearest neighbors.
apparently the distance calculus is doing with the euclidian distance, not with the chi square distance.
There is a problem in my code?

Thanks,
Marzieh

from flann.

mariusmuja avatar mariusmuja commented on August 18, 2024

Hi Marzieh,

Your code looks fine, it should use the chi square distance. How did you
verify that is the euclidean distance instead?

Marius

On Fri, Aug 17, 2012 at 12:19 AM, Marzounette [email protected]:

Thanks for your response Marius.

Yes, i use the C bindings with FLANN 1.7.1.
Here is a snippet of my code :
//
FLANNParameters flann_params;
flann_params.checks = FLANN_CHECKS_UNLIMITED;
flann_params.eps = 0.0;
flann_params.trees = 1;
flann_params.algorithm = FLANN_INDEX_KDTREE;
flann_set_distance_type( FLANN_DIST_CHI_SQUARE, 0);

flann_index_t index_ptr;
flann_find_nearest_neighbors_index( index_ptr, testset, tcount, result,
dists, nn, flann_params);
//

I'm looking for the nn exact nearest neighbors.

apparently the distance calculus is doing with the euclidian distance, not
with the chi square distance.
There is a problem in my code?

Thanks,
Marzieh


Reply to this email directly or view it on GitHubhttps://github.com//issues/60#issuecomment-7811500.

from flann.

Marzounette avatar Marzounette commented on August 18, 2024

with printing in L2 and chisquare distance. Only L2 distance is actually performed.

Marzieh

from flann.

mariusmuja avatar mariusmuja commented on August 18, 2024

I cannot reproduce this. I've done the following changes:
added flann_set_distance_type( FLANN_DIST_CHI_SQUARE, 0); to examples/flann_example.c
and added printfs to L2 and ChiSquare distances in src/cpp/flann/algorithms/dists.h (see patch below)

If I recompile and run flann_example_c only the ChiSquare message gets printed.

Regards,
Marius

diff -Naur flann-1.7.1-src/examples/flann_example.c flann-1.7.1-src_/examples/flann_example.c
--- flann-1.7.1-src/examples/flann_example.c    2011-12-26 02:17:13.000000000 -0800
+++ flann-1.7.1-src_/examples/flann_example.c   2012-08-29 11:58:54.000000000 -0700
@@ -98,6 +98,7 @@
     p.trees = 8;
     p.log_level = FLANN_LOG_INFO;
        p.checks = 64;
+    flann_set_distance_type( FLANN_DIST_CHI_SQUARE, 0);

     printf("Computing index.\n");
     index_id = flann_build_index(dataset, rows, cols, &speedup, &p);
diff -Naur flann-1.7.1-src/src/cpp/flann/algorithms/dist.h flann-1.7.1-src_/src/cpp/flann/algorithms/dist.h
--- flann-1.7.1-src/src/cpp/flann/algorithms/dist.h     2011-12-26 02:17:13.000000000 -0800
+++ flann-1.7.1-src_/src/cpp/flann/algorithms/dist.h    2012-08-29 11:59:48.000000000 -0700
@@ -138,6 +138,7 @@
     template <typename Iterator1, typename Iterator2>
     ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
     {
+        printf("In  L2 dist\n");
         ResultType result = ResultType();
         ResultType diff0, diff1, diff2, diff3;
         Iterator1 last = a + size;
@@ -683,6 +684,7 @@
     template <typename Iterator1, typename Iterator2>
     ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
     {
+        printf("In ChiSquare dist\n");
         ResultType result = ResultType();
         ResultType sum, diff;
         Iterator1 last = a + size;

from flann.

Related Issues (20)

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.