Ask Your Question

Revision history [back]

hierarchical Clustering VS Kmeans Clustering

What is difference between hierarchical Clustering & Kmeans clustering?What is advantage of hierarchical Clustering to Kmeans clustering?

hierarchical Clustering VS Kmeans Clustering

What is difference between hierarchical Clustering & Kmeans clustering?What is advantage of hierarchical Clustering to Kmeans clustering?


EDIT 1 (from other question):

I use this code:

int c_count =cv::flann::hierarchicalClustering<L2<float>  >(data,cluster,kmeans_param);

I got this error:

 error C2146: syntax error : missing ';' before identifier 'ElementType'

How can I solve it?

My features is 3d (x,y,theta) that I want to cluster these. when the classification was done.How can I access to cluster id for each feature?


EDIT 2 (from other question):

I solve it by below code.But i got warning.What is the reason?

[WARNING] cv::flann::hierarchicalClustering<elem_type,dist_type> is deprecated, use " "cv::flann::hierarchicalClustering<distance> instead

code:

Mat1f cluster_data(15,3);
cluster_data(0,0) = 1;  cluster_data(0,1) = 1;cluster_data(0,2) = 1;
cluster_data(1,0) = 2;  cluster_data(1,1) = 2;cluster_data(1,2) = 1;
cluster_data(2,0) = 2;  cluster_data(2,1) = 1;cluster_data(2,2) = 1;
cluster_data(3,0) = 1;  cluster_data(3,1) = 1;cluster_data(3,2) = 2;
cluster_data(4,0) = 1;  cluster_data(4,1) = 2;cluster_data(4,2) = 2;


cluster_data(5,0) = 100;    cluster_data(5,1) = 99;cluster_data(5,2) = 98;
cluster_data(6,0) = 101;    cluster_data(6,1) = 100;cluster_data(6,2) = 99;
cluster_data(7,0) = 103;    cluster_data(7,1) = 90;cluster_data(7,2) = 97;
cluster_data(8,0) = 99; cluster_data(8,1) = 98;cluster_data(8,2) = 102;
cluster_data(9,0) = 98; cluster_data(9,1) = 100;cluster_data(9,2) = 102;

cluster_data(10,0) = 1001;  cluster_data(10,1) = 997;cluster_data(10,2) = 996;
cluster_data(11,0) = 1002;  cluster_data(11,1) = 1001;cluster_data(11,2) = 999;
cluster_data(12,0) = 1000;  cluster_data(12,1) = 999;cluster_data(12,2) = 998;
cluster_data(13,0) = 999;   cluster_data(13,1) = 998;cluster_data(13,2) = 1000;
cluster_data(14,0) = 998;   cluster_data(14,1) = 1003;cluster_data(14,2) = 1003;



cvflann::KMeansIndexParams k_params(10, 1000, cvflann::FLANN_CENTERS_KMEANSPP,0.01);

Mat1f centers(10,3);
centers.setTo(0);

int count = cv::flann::hierarchicalClustering<float,L2<float> >(cluster_data,centers,k_params);
cout << cluster_data << endl;

cout << centers << endl;

hierarchical Clustering VS Kmeans Clustering

What is difference between hierarchical Clustering & Kmeans clustering?What is advantage of hierarchical Clustering to Kmeans clustering?


EDIT 1 (from other question):

I use this code:

int c_count =cv::flann::hierarchicalClustering<L2<float>  >(data,cluster,kmeans_param);

I got this error:

 error C2146: syntax error : missing ';' before identifier 'ElementType'

How can I solve it?

My features is 3d (x,y,theta) that I want to cluster these. when the classification was done.How can I access to cluster id for each feature?


EDIT 2 (from other question):

I solve it by below code.But i got warning.What is the reason?

[WARNING] cv::flann::hierarchicalClustering<elem_type,dist_type> is deprecated, use " "cv::flann::hierarchicalClustering<distance> instead

code:

Mat1f cluster_data(15,3);
cluster_data(0,0) = 1;  cluster_data(0,1) = 1;cluster_data(0,2) = 1;
cluster_data(1,0) = 2;  cluster_data(1,1) = 2;cluster_data(1,2) = 1;
cluster_data(2,0) = 2;  cluster_data(2,1) = 1;cluster_data(2,2) = 1;
cluster_data(3,0) = 1;  cluster_data(3,1) = 1;cluster_data(3,2) = 2;
cluster_data(4,0) = 1;  cluster_data(4,1) = 2;cluster_data(4,2) = 2;


cluster_data(5,0) = 100;    cluster_data(5,1) = 99;cluster_data(5,2) = 98;
cluster_data(6,0) = 101;    cluster_data(6,1) = 100;cluster_data(6,2) = 99;
cluster_data(7,0) = 103;    cluster_data(7,1) = 90;cluster_data(7,2) = 97;
cluster_data(8,0) = 99; cluster_data(8,1) = 98;cluster_data(8,2) = 102;
cluster_data(9,0) = 98; cluster_data(9,1) = 100;cluster_data(9,2) = 102;

cluster_data(10,0) = 1001;  cluster_data(10,1) = 997;cluster_data(10,2) = 996;
cluster_data(11,0) = 1002;  cluster_data(11,1) = 1001;cluster_data(11,2) = 999;
cluster_data(12,0) = 1000;  cluster_data(12,1) = 999;cluster_data(12,2) = 998;
cluster_data(13,0) = 999;   cluster_data(13,1) = 998;cluster_data(13,2) = 1000;
cluster_data(14,0) = 998;   cluster_data(14,1) = 1003;cluster_data(14,2) = 1003;



cvflann::KMeansIndexParams k_params(10, 1000, cvflann::FLANN_CENTERS_KMEANSPP,0.01);

Mat1f centers(10,3);
centers.setTo(0);

int count = cv::flann::hierarchicalClustering<float,L2<float> >(cluster_data,centers,k_params);
cout << cluster_data << endl;

cout << centers << endl;