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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
#!/usr/bin/perl
use Data::Dumper;
use POSIX;
use Math::BigFloat;
$path = "/home/lukesky/rl-thesis/doc";
@algorithms = ({ALGO => 'fann_cascade_rprop_one_activation', NAME => 'C2 RPROP One'},
{ALGO => 'fann_cascade_rprop_multi_activation', NAME => 'C2 RPROP Multi'},
{ALGO => 'fann_cascade_quickprop_one_activation', NAME => 'C2 Quickprop One'},
{ALGO => 'fann_cascade_quickprop_multi_activation', NAME => 'C2 Quickprop Multi'},
{ALGO => 'fann_rprop', NAME => 'iRPROP$^{-}$'},
{ALGO => 'fann_quickprop', NAME => 'Quickprop'},
{ALGO => 'fann_batch', NAME => 'Batch'},
{ALGO => 'fann_incremental_momentum', NAME => 'Incremental'},
{ALGO => 'lwnn', NAME => 'Lwnn Incr.'},
{ALGO => 'jneural', NAME => 'Jneural Incr.'});
#This is not used yet
%dataSetType = {'abelone' => 'R',
'bank32fm' => 'R',
'bank32nh' => 'R',
'kin32fm' => 'R',
'census-house' => 'R',
'building' => 'R',
'diabetes' => 'C',
'gene' => 'C',
'mushroom' => 'C',
'parity8' => 'C',
'parity13' => 'C',
'pumadyn-32fm' => 'R',
'robot' => 'R',
'soybean' => 'C',
'thyroid' => 'C',
'two-spiral' => 'C'};
$oldDataSet = "";
$numDataSet = 0;
while(<>)
{
chop;
@data = split / /;
@words = split(/\./, @data[0]);
$dataSet = @words[0];
$algoritm = @words[1];
$test_train = @words[2];
$mse = Math::BigFloat->new(@data[2]);
$meanbitfail = Math::BigFloat->new(@data[5]);
if($oldDataSet ne $dataSet && $oldDataSet ne "")
{
$numDataSet++;
print "**$oldDataSet**\n";
@test = keys(%summary);
#calculate min and max mse
$min_test_mse = 100;
$min_train_mse = 100;
$max_test_mse = -100;
$max_train_mse = -100;
while(($algo, $foo) = each(%summary))
{
if($foo->{'test'} < $min_test_mse)
{
$min_test_mse = $foo->{'test'};
}
if($foo->{'train'} < $min_train_mse)
{
$min_train_mse = $foo->{'train'};
}
if($foo->{'test'} > $max_test_mse)
{
$max_test_mse = $foo->{'test'};
}
if($foo->{'train'} > $max_train_mse)
{
$max_train_mse = $foo->{'train'};
}
}
#Adds rank to each set and calculates percent etc.
for($i = 1; $i <= scalar(%summary)+2; $i++)
{
$min_algo_test = 0;
$min_algo_train = 0;
while(($algo, $foo) = each(%summary))
{
if(!exists($foo->{'test_rank'}) && (!$min_algo_test || $foo->{'test'} < $summary{$min_algo_test}->{'test'}))
{
$min_algo_test = $algo;
}
if(!exists($foo->{'train_rank'}) && (!$min_algo_train || $foo->{'train'} < $summary{$min_algo_train}->{'train'}))
{
$min_algo_train = $algo;
}
}
$summary{$min_algo_test}->{'test_rank'} = $i;
$summary{$min_algo_train}->{'train_rank'} = $i;
$summary{$min_algo_test}->{'test_percent'} = (($summary{$min_algo_test}->{'test'}-$min_test_mse)*100)/($max_test_mse-$min_test_mse);
$summary{$min_algo_train}->{'train_percent'} = (($summary{$min_algo_train}->{'train'}-$min_train_mse)*100)/($max_train_mse-$min_train_mse);
}
#write tex to file
open(OUT, "> $path/".$oldDataSet."_table.tex") or die("unable to open file $path/".$oldDataSet."_table.tex");
print OUT '\begin{tabular} {|l|r|r|r|r|r|r|}'."\n";
print OUT '\hline'."\n";
print OUT '& \multicolumn{3}{c|}{\textbf{Best Train}} & \multicolumn{3}{c|}{\textbf{Best Test}} \\\\'."\n";
print OUT '\hline'."\n";
print OUT '\textbf{Configuration} & \textbf{MSE} & \textbf{Rank} & \textbf{\%} & \textbf{MSE} & \textbf{Rank} & \textbf{\%} \\\\'."\n";
print OUT '\hline'."\n";
foreach $algo (@algorithms)
{
$foo = $summary{$algo->{ALGO}};
printf OUT ("%s & %.8f & %d & %.2f & %.8f & %d & %.2f\\\\\n\\hline\n",
$algo->{NAME},
$foo->{'train'}, $foo->{'train_rank'}, $foo->{'train_percent'},
$foo->{'test'}, $foo->{'test_rank'}, $foo->{'test_percent'});
$total{$algo->{ALGO}}->{'train'} += $foo->{'train'};
$total{$algo->{ALGO}}->{'test'} += $foo->{'test'};
$total{$algo->{ALGO}}->{'train_percent'} += $foo->{'train_percent'};
$total{$algo->{ALGO}}->{'test_percent'} += $foo->{'test_percent'};
$total{$algo->{ALGO}}->{'train_rank'} += $foo->{'train_rank'};
$total{$algo->{ALGO}}->{'test_rank'} += $foo->{'test_rank'};
}
print OUT '\end{tabular}'."\n";
close(OUT);
undef(%summary);
}
$summary{$algoritm}->{$test_train} = $mse;
$oldDataSet = $dataSet;
}
print "**Average**\n";
open(OUT, "> $path/average_table.tex") or die("unable to open file $path/average_table.tex");
print OUT '\begin{tabular} {|l|r|r|r|r|r|r|}'."\n";
print OUT '\hline'."\n";
print OUT '& \multicolumn{3}{c|}{\textbf{Best Train}} & \multicolumn{3}{c|}{\textbf{Best Test}} \\\\'."\n";
print OUT '\hline'."\n";
print OUT '\textbf{Configuration} & \textbf{MSE} & \textbf{Rank} & \textbf{\%} & \textbf{MSE} & \textbf{Rank} & \textbf{\%} \\\\'."\n";
print OUT '\hline'."\n";
foreach $algo (@algorithms)
{
$foo = $total{$algo->{ALGO}};
printf OUT ("%s & %.6f & %.2f & %.2f & %.6f & %.2f & %.2f\\\\\n\\hline\n",
$algo->{NAME},
$foo->{'train'}/$numDataSet, $foo->{'train_rank'}/$numDataSet, $foo->{'train_percent'}/$numDataSet,
$foo->{'test'}/$numDataSet, $foo->{'test_rank'}/$numDataSet, $foo->{'test_percent'}/$numDataSet);
}
print OUT '\end{tabular}'."\n";
close(OUT);
|