#! /bin/bash # This version assumes the attributes have already been ranked and saved to $RankingFile # Arguments # ./attr $Filename $Path $Ranker $TestFile $TrainFile $LogFile $Horizon $RankingFile $SortingFile $Eval $Search Filename=$1 Path=$2 Ranker=$3 TestFile=$4 TrainFile=$5 LogFile=$6 Horizon=$7 RankingFile=$8 SortingFile=$9 Eval=${10} Search=${11} EMstart=1 EMend=15 Stale=$Horizon Subset="" i=$EMstart # Set up the Ranking criteria for evaluating attributes if [ $Ranker = "correlation" ] then SortColumn=2 Reverse=1 fi if [ $Ranker = "variance_high" ] then SortColumn=3 Reverse=1 fi if [ $Ranker = "variance_low" ] then SortColumn=3 Reverse=-1 fi if [ $Ranker = "entropy_high" ] then SortColumn=4 Reverse=1 fi if [ $Ranker = "entropy_low" ] then SortColumn=4 Reverse=-1 fi # Set up the Evaluation criteria for finding improvement if [ $Eval = "mmre" ] then EvalColumn=1 EvalDef=1 fi if [ $Eval = "sd_mre" ] then EvalColumn=2 EvalDef=1 fi if [ $Eval = "pred30" ] then EvalColumn=3 EvalDef=0 fi if [ $Eval = "correlation" ] then EvalColumn=4 EvalDef=0 fi if (($EvalDef==1)) then NewValue=99999 else NewValue=-99999 fi if [ $Search = "backward" ] then Reverse=$((Reverse*-1)) fi if ((Reverse==1)) then sort -t, -nrk$SortColumn $RankingFile > $SortingFile else sort -t, -nk$SortColumn $RankingFile > $SortingFile fi while ((i<=EMend)) do NewSubset=$Subset$(gawk -v x=$i 'BEGIN{FS=","} NR==x{print $1}' $SortingFile) # If this is a backward elimination search then invert the subset. if [ $Search = "backward" ] then tmpSubset=$(./inverse $NewSubset $EMstart $EMend) else tmpSubset=$NewSubset fi # Try Local Calibration using the Subset. #EffortResult=$(./effort $Filename $Path "simpleLC" $TestFile $TrainFile $tmpSubset $LogFile"."$i) EffortResult=$(./effort $Filename $Path "simpleLC" $TrainFile $TrainFile $tmpSubset $LogFile"."$i) OldValue=$NewValue NewValue=$(echo $EffortResult | gawk -v EvalColumn=$EvalColumn 'BEGIN{FS=","} {print $EvalColumn}') # Test the new value and handle Subset Selection Keep=$(gawk -v a=$NewValue -v b=$OldValue 'BEGIN{print a