*** empty log message ***
[folded-ctf.git] / graph.sh
1 #!/bin/bash
2
3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify  #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation.                         #
7 #                                                                       #
8 # This program is distributed in the hope that it will be useful, but   #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of            #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      #
11 # General Public License for more details.                              #
12 #                                                                       #
13 # You should have received a copy of the GNU General Public License     #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.  #
15 #                                                                       #
16 # Written and (C) by Francois Fleuret                                   #
17 # Contact <francois.fleuret@idiap.ch> for comments & bug reports        #
18 #########################################################################
19
20 echo "Parsing the log files"
21
22 for p in hb h+b; do
23     grep ^INFO results/${p}-*/log  | grep "FALSE_NEGATIVE_RATE\|PER_VGA" | \
24         sed -e "s/[^0-9A-Z_ .]//g" | \
25         awk '{
26                if($2 == "DECIMATED_FALSE_NEGATIVE_RATE") {
27                  printf(1-$3)
28                } else {
29                  printf(" "$3"\n")
30                }
31              }' | sort -g > /tmp/${p}
32
33 done
34
35 if [[ ! -s /tmp/hb ]] || [[ ! -s /tmp/h+b ]]; then
36     echo "Not enough data points." >&2
37     exit 1
38 fi
39
40 ######################################################################
41
42 echo "Generating the graph per se"
43
44 GRAPH_NAME="/tmp/roc.eps"
45
46 gnuplot<<EOF
47   set terminal postscript enhanced eps "Helvetica" 20
48   set key 80,0.25
49   set output "${GRAPH_NAME}"
50   set logscale x
51   set xlabel "Number of false alarms per 640x480"
52   set ylabel "True positive rate"
53   set grid
54
55   plot [1e-3:100][0.0:1.0] \
56      '/tmp/hb' using 2:1 title "HB" pt 7 ps 1.0 lc 1 lw 1,\
57      '/tmp/h+b' using 2:1 title "H+B" pt 7 ps 1.0 lc 3 lw 1
58 EOF
59
60 ######################################################################
61
62 echo "Graph saved in ${GRAPH_NAME}"