Added README.md
[clueless-kmeans.git] / test.sh
diff --git a/test.sh b/test.sh
index d89deb1..64b69ee 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1,19 +1,18 @@
 #!/bin/bash
 
-
-# clueless-kmean is a variant of k-mean which enforces balanced
+# clueless-kmeans is a variant of k-means which enforces balanced
 # distribution of classes in every cluster
 #
 # Copyright (c) 2013 Idiap Research Institute, http://www.idiap.ch/
 # Written by Francois Fleuret <francois.fleuret@idiap.ch>
 #
-# This file is part of clueless-kmean.
+# This file is part of clueless-kmeans.
 #
-# clueless-kmean is free software: you can redistribute it and/or
+# clueless-kmeans is free software: you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # version 3 as published by the Free Software Foundation.
 #
-# clueless-kmean is distributed in the hope that it will be useful,
+# clueless-kmeans is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # General Public License for more details.
 
 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 <<EOF
+    gnuplot <<EOF
 set terminal pngcairo truecolor size 1024,768
-set output "result.png"
+set output "$1"
 set size ratio 1
 set key out vert
 set key left top
@@ -52,3 +48,18 @@ plot [-1.2:1.2][-1.2:1.2] "< grep ^0 associated_clusters.dat" using 2:3 w p lc r
                           "< grep ^2 clusters.dat"            using 2:3 w p lc rgb "#ffffff" pt 2 lw 9 ps 4.0 notitle, \
                           "< grep ^2 clusters.dat"            using 2:3 w p lc rgb "#0000c0" pt 2 lw 4 ps 4.0 title "Centroid 3"
 EOF
+}
+
+make -j -k
+
+echo "Baseline k-mean"
+./clueless-kmeans standard
+make_graph result-standard.png
+
+echo "Clueless k-mean"
+./clueless-kmeans clueless
+make_graph result-clueless.png
+
+echo "Clueless-absolute k-mean"
+./clueless-kmeans clueless-absolute
+make_graph result-clueless-absolute.png