automatic commit
[folded-ctf.git] / graph.sh
diff --git a/graph.sh b/graph.sh
new file mode 100755 (executable)
index 0000000..b54fcf4
--- /dev/null
+++ b/graph.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+#########################################################################
+# This program is free software: you can redistribute it and/or modify  #
+# it under the terms of the version 3 of the GNU General Public License #
+# as published by the Free Software Foundation.                         #
+#                                                                       #
+# This program 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.                              #
+#                                                                       #
+# You should have received a copy of the GNU General Public License     #
+# along with this program. If not, see <http://www.gnu.org/licenses/>.  #
+#                                                                       #
+# Written and (C) by Francois Fleuret                                   #
+# Contact <francois.fleuret@idiap.ch> for comments & bug reports        #
+#########################################################################
+
+echo "Parsing the log files"
+
+for p in hb h+b; do
+    grep ^INFO results/${p}-*/log  | grep "FALSE_NEGATIVE_RATE\|PER_VGA" | \
+        sed -e "s/[^0-9A-Z_ .]//g" | \
+        awk '{
+               if($2 == "DECIMATED_FALSE_NEGATIVE_RATE") {
+                 printf(1-$3)
+               } else {
+                 printf(" "$3"\n")
+               }
+             }' | sort -g > /tmp/${p}
+
+done
+
+if [[ ! -s /tmp/hb ]] || [[ ! -s /tmp/h+b ]]; then
+    echo "Not enough data points." >&2
+    exit 1
+fi
+
+######################################################################
+
+echo "Generating the graph per se"
+
+GRAPH_NAME="/tmp/roc.eps"
+
+gnuplot<<EOF
+  set terminal postscript enhanced eps "Helvetica" 20
+  set key 80,0.25
+  set output "${GRAPH_NAME}"
+  set logscale x
+  set xlabel "Number of false alarms per 640x480"
+  set ylabel "True positive rate"
+  set grid
+
+  plot [1e-3:100][0.0:1.0] \
+     '/tmp/hb' using 2:1 title "HB" pt 7 ps 1.0 lc 1 lw 1,\
+     '/tmp/h+b' using 2:1 title "H+B" pt 7 ps 1.0 lc 3 lw 1
+EOF
+
+######################################################################
+
+echo "Graph saved in ${GRAPH_NAME}"