SimpleDBSCAN icon indicating copy to clipboard operation
SimpleDBSCAN copied to clipboard

usage question

Open omerbrandis opened this issue 3 years ago • 2 comments

hello ,

[thanks for sharing this lib, its very easy to use :-) ]

these are my first steps with dbscan, so i'm not sure if the problem i've encoutered is due to the algorithm itself , or the implementation , or my client code.

here's my code

struct vec3f {
        float data[3];
        float operator[](int idx) const { return data[idx]; }
    };


DBSCAN<vec3f, float> Clusterer;
std::vector<vec3f>   Data;
Data.push_back(vec3f{1,1,1});
Data.push_back(vec3f{2,1,1});
Data.push_back(vec3f{3,1,1});
int Rc = Clusterer.Run(&Data,3,1.0f,2);

the result has {2,1,1} in clusterer.clusters , as expected, but points {1,1,1} & {3,1,1} are in Noise, and not part of the cluster. can anyone help me figure this out ?

thanks, Omer.

omerbrandis avatar Apr 11 '22 10:04 omerbrandis

image

I have tested your code, but the result seems good... Maybe you can replace your Integer with float ?

Data.push_back( vec3f{1.0f, 1.0f, 1.0f} );

CallmeNezha avatar Apr 17 '22 07:04 CallmeNezha

thank you CallmeNezha for reaching out & trying to help me :-) ,

I've tried changing to float, results remained the same.

maybe the problem is in the way with which i check the results:

std::cout << "Noise indexes : " ;
    for (std::vector<uint>::const_iterator It = Clusterer.Noise.begin(); It!=Clusterer.Noise.end();It++) std::cout << *It << " ";
    std::cout << std::endl;


    for (std::vector<std::vector<uint>>::const_iterator OuterIt = Clusterer.Clusters.begin();OuterIt != Clusterer.Clusters.end(); OuterIt++)
    {
        std::cout << "Cluster " << OuterIt - Clusterer.Clusters.begin() << " indexes : ";
        for (std::vector<uint>::const_iterator InnerIt = OuterIt->begin(); InnerIt != OuterIt->end(); InnerIt++) std::cout << *InnerIt << " ";
        std::cout << std::endl;

    }
    std::cout << std::endl;

returned : Noise indexes : 0 2 Cluster 0 indexes : 1

(I realize this seems to disagree with the screen shoot of your debugger, but can not explain it ) :-) Omer.

omerbrandis avatar Apr 25 '22 10:04 omerbrandis