Blame view

tools/PACKAGE_MESURES_V1.0/TrainBoosting.sh 3.72 KB
e6be5137b   Jean-François Rey   reinitialized pro...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  #!/bin/bash
  #-----------------------------------------------------------------------------------------
  # Author : Benjamin Lecouteux & Emmanuel FERREIRA (contact emmanuel.ferreira0194@gmail.com)
  # Brief: Phase d'apprentissage du classifieur pour les measure de confiance
  #
  #-----------------------------------------------------------------------------------------
  
  ROOT=$OTMEDIA_HOME/PACKAGE_MESURES_V1.0
  TRAIN_CONF=$OTMEDIA_HOME/data/cfg/train_boosting_package_measure.cfg
  
  #------------------
  # Parser les options
  #-------------------
  while getopts ":c:h" OPTION
  do
  	case $OPTION in
  	h) 	#Display help
  		echo -e "$0 :"
  		echo -e "\tAuthor : Benjamin Lecouteux & Emmanuel FERREIRA (contact: emmanuel.ferreira0194@gmail.com)"
  		echo -e "\tVersion : 2.0"
  		echo -e "\tBrief : Process the boosting training"
  		echo -e "\tUsage : $0 [OPTIONS]"
  		echo -e "\tOptions:"
  		echo -e "\t\tc) specify the path of the configuration file (default $TRAIN_CONF)"
  		exit 1
  	;;
  	c) 	TRAIN_CONFG=$OPTARG
  	;;
  	:)
  		echo "BAD USAGE : OPTION $OPTARG need a value"
  	   	exit 1
  	;;
  	\?) 
  		echo "BAD USAGE : unknow option '$OPTARG'"
  	   	exit 1 
  	;;
  	esac
  done
  
  #-------------------------------------------
  # Shift options pour recuperation arguments
  #-------------------------------------------
  shift $((OPTIND-1))
  
  #-------------
  # Load config
  #-------------
  . $TRAIN_CONF
  
  #----------------
  # INIT WORKSPACE
  #----------------
  ALL_SUPER_CTM_TEST=$ROOT/ALL_SUPER_CTM_TEST
  ALL_SUPER_CTM_DEV=$ROOT/ALL_SUPER_CTM_TRAIN
  if [ ! -z $BOOST_BIN ];then
  	BOOST_BIN=$ROOT/bin/icsiboost-64bit-static-r160
  fi
  	
  mkdir -p $ALL_SUPER_CTM_TEST
  mkdir -p $ALL_SUPER_CTM_DEV
  rm -f $ALL_SUPER_CTM_TEST/* $ALL_SUPER_CTM_DEV/* $ROOT/Mots* $ROOT/ERR_* $ROOT/OK_* $ROOT/TRAIN.[dts]* $ROOT/resultatsT*
  	
  $ROOT/script/AnalyserErreursAvecPRF_EtTaggerLesFichiersRES.pl $DEV_PRF ERR > $ROOT/MotsFauxDev.lst
  $ROOT/script/AnalyserErreursAvecPRF_EtTaggerLesFichiersRES.pl $DEV_PRF OK  > $ROOT/MotsVraiDev.lst
  $ROOT/script/AnalyserErreursAvecPRF_EtTaggerLesFichiersRES.pl $TEST_PRF ERR > $ROOT/MotsFauxTest.lst
  $ROOT/script/AnalyserErreursAvecPRF_EtTaggerLesFichiersRES.pl $TEST_PRF OK  > $ROOT/MotsVraiTest.lst
  
  for i in `cat $HEURES_DEV` ; do for j in `ls $REP_IN_DEV/${i}_SUPER_CTM/`; do cp $REP_IN_DEV/${i}_SUPER_CTM/$j $ALL_SUPER_CTM_DEV; done; done
  for i in `cat $HEURES_TEST`; do for j in `ls $REP_IN_TEST/${i}_SUPER_CTM/`; do cp $REP_IN_TEST/${i}_SUPER_CTM/$j $ALL_SUPER_CTM_TEST; done; done
  
  $ROOT/script/DissociateErroneousFromDecodedTrain.pl $ROOT/MotsFauxDev.lst $ALL_SUPER_CTM_DEV 2 equilibre ERR > $ROOT/ERR_DEV.sctm
  $ROOT/script/DissociateErroneousFromDecodedTrain.pl $ROOT/MotsVraiDev.lst $ALL_SUPER_CTM_DEV 2 equilibre OK > $ROOT/OK_DEV.sctm
  $ROOT/script/DissociateErroneousFromDecodedTrain.pl $ROOT/MotsFauxTest.lst $ALL_SUPER_CTM_TEST 2 equilibre ERR > $ROOT/ERR_TEST.sctm
  $ROOT/script/DissociateErroneousFromDecodedTrain.pl $ROOT/MotsVraiTest.lst $ALL_SUPER_CTM_TEST 2 equilibre OK > $ROOT/OK_TEST.sctm
  
  $ROOT/script/ConvertSuperCTMtoDataSVM.pl $ROOT/ERR_DEV.sctm boost 2 0 0 > $ROOT/ERR_DEV.boost
  $ROOT/script/ConvertSuperCTMtoDataSVM.pl $ROOT/OK_DEV.sctm boost 2 0 0 > $ROOT/OK_DEV.boost
  $ROOT/script/ConvertSuperCTMtoDataSVM.pl $ROOT/ERR_TEST.sctm boost 2 0 0 > $ROOT/ERR_TEST.boost
  $ROOT/script/ConvertSuperCTMtoDataSVM.pl $ROOT/OK_TEST.sctm boost 2 0 0 > $ROOT/OK_TEST.boost
  
  cat $ROOT/ERR_DEV.boost $ROOT/OK_DEV.boost > $ROOT/TRAIN.data
  cat $ROOT/ERR_TEST.boost $ROOT/OK_TEST.boost > $ROOT/TRAIN.test
  
  #------------------
  # TRAINING
  #------------------
  $BOOST_BIN -S $ROOT/TRAIN --jobs 16 -n 1000
  $BOOST_BIN -S $ROOT/TRAIN -C --posteriors < $ROOT/TRAIN.data > $ROOT/resultatsTRAIN.res
  $BOOST_BIN -S $ROOT/TRAIN -C --posteriors < $ROOT/TRAIN.test > $ROOT/resultatsTEST.res
  
  $ROOT/script/optimal_threshold.pl -bs < $ROOT/resultatsTRAIN.res