From 379b91965f8d18b05cc40c4a14044eda29a6e82c Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sun, 19 May 2013 00:02:59 +0200 Subject: [PATCH] clueless-kmean now takes as parameter in which mode to work, and test.sh generate two result images. --- clueless-kmean.cc | 19 +++++++++++++++++-- clusterer.h | 1 + test.sh | 24 +++++++++++++++--------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/clueless-kmean.cc b/clueless-kmean.cc index e3d4f93..557f0d8 100644 --- a/clueless-kmean.cc +++ b/clueless-kmean.cc @@ -76,8 +76,23 @@ int main(int argc, char **argv) { glp_term_out(0); - clusterer.train(Clusterer::UNINFORMATIVE_LP_ASSOCIATION, - // Clusterer::STANDARD_LP_ASSOCIATION, + int mode; + + if(argc == 2) { + if(strcmp(argv[1], "standard") == 0) { + mode = Clusterer::STANDARD_LP_ASSOCIATION; + } else if(strcmp(argv[1], "clueless") == 0) { + mode = Clusterer::UNINFORMATIVE_LP_ASSOCIATION; + } else { + cerr << "Unknown association mode " << argv[1] << endl; + exit(EXIT_FAILURE); + } + } else { + cerr << "Usage: " << argv[0] << " standard|clueless" << endl; + exit(EXIT_FAILURE); + } + + clusterer.train(mode, nb_clusters, sample_set.dim, sample_set.nb_points, sample_set.points, diff --git a/clusterer.h b/clusterer.h index ad0c58f..a0a29f9 100644 --- a/clusterer.h +++ b/clusterer.h @@ -42,6 +42,7 @@ public: int _nb_clusters; int _dim; + scalar_t **_cluster_means, **_cluster_var; scalar_t distance_to_centroid(scalar_t *x, int k); diff --git a/test.sh b/test.sh index d89deb1..51735ee 100755 --- a/test.sh +++ b/test.sh @@ -23,17 +23,14 @@ set -e -make -j -k - -./clueless-kmean +function make_graph () { + CLUSTER1=($(grep ^0 clusters.dat)) + CLUSTER2=($(grep ^1 clusters.dat)) + CLUSTER3=($(grep ^2 clusters.dat)) -CLUSTER1=($(grep ^0 clusters.dat)) -CLUSTER2=($(grep ^1 clusters.dat)) -CLUSTER3=($(grep ^2 clusters.dat)) - -gnuplot <