#!/bin/bash # $1 - File to crossvalidate on # $2 - LOC attribute # $3 - Discretization Type # $4 - Bin number # $5 - Save Path # $6 - Sample Rate for crossvalidation. path=../Data/whichData/mdp; files=$path/$1".data" savePath=$5; for file in $files do stem=`basename $file .data`; ./which -f $path/$stem -disc $3 $4 -s ee $2 > temporary; rm -f temporary; rm -f $stem"_results"; ./makeTrainTest file=$stem sample=$6 $stem"Discr.data"; for ((i=0;i<$6;i++)) do echo "Pass $(($i+1)) on $stem with $3 $4 binning"; cp "train"$i$stem train.data cp "test"$i$stem test.data; cp $stem"Discr.names" test.names; cp $stem"Discr.names" train.names; ./which -f train -p 2000 -s ee $2 -z -1 -r 1 -o 1 500 -b 30 -beta 10 | ./getRules Pass=1 > rule; ./which -f test -s ee $2 -test rule -b 30 | gawk '{x=$0;}END{print x "," no;}' no=$(($i+1)) >> $stem"_results"; echo "Rule generated at crossval - $(($i+1))" >> $stem"rule"; cat wr >> $stem"rule"; echo "" >> $stem"rule"; rm -f test.names train.names test.data train.data "train"$i$stem "test"$i$stem rule wr; done mv $stem"rule" $savePath/rules/$stem; rm -f $stem"Discr".*; echo "Score,PD,PF,Effort,Support,Run #" > $stem"_resultst"; echo "--------,-------,-------,,---------------,------" >> $stem"_resultst"; sort -k 1 $stem"_results" >> $stem"_resultst"; rm -f $stem"_results" cat $stem"_resultst" | malign > $stem"_results"; cat $stem"_results"; rm -f $stem"_resultst"; gawk 'BEGIN{FS=OFS=",";cnt=0;}{cnt++;}cnt>2{gsub( ",", " " ); print; }' $stem"_results" > $stem; echo "#!/usr/bin/gnuplot -persist set title \"$stem using PD, PF, Effort, Euclidian Distance Score\" set output \"$stem.ps\" set terminal postscript eps color enhanced plot \"$stem\" using 1:2 t \"PD\" with linespoints, \"$stem\" using 1:3 t \"PF\" with linespoints, \"$stem\" using 1:4 t \"Effort\" with linespoints" > $stem"Plot"; chmod +x $stem"Plot"; ./$stem"Plot"; epstopdf $stem.ps; mv $stem"_results" $savePath/tables/$stem; mv $stem".pdf" $savePath/plots/$stem".pdf"; rm -f $stem"_results"; rm -f $stem"Plot"; rm -f $stem"Data"; rm -f $stem".ps"; rm -f $stem"1"; rm -f $stem; done