From: Aaron A. <aa...@us...> - 2007-12-13 01:30:37
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18494 Modified Files: atree2dot2ps.pl Log Message: MultiPredictions now handled Index: atree2dot2ps.pl =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/atree2dot2ps.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** atree2dot2ps.pl 16 Oct 2007 02:02:27 -0000 1.5 --- atree2dot2ps.pl 13 Dec 2007 01:30:27 -0000 1.6 *************** *** 14,19 **** print "$0 usage: \n"; print "\t -i (--info) file.info \t File containing runtime information (required) \n"; print "\t -t (--tree) file.tree \t File containing the ADTree in text format (required) \n"; ! print "\t -d (--dir) directiory\t Directory to use (optional, defaults to '.') \n"; print "\t -l (--labels) \t Flip the labels (-1 becomes +1) (optional)\n"; print "\t --truncate \t Truncate threshold values to increase readability\n"; --- 14,20 ---- print "$0 usage: \n"; print "\t -i (--info) file.info \t File containing runtime information (required) \n"; + print "\t -s (--spec) file.spec \t Spec file (optional, will default to spec file in info file) \n"; print "\t -t (--tree) file.tree \t File containing the ADTree in text format (required) \n"; ! print "\t -d (--dir) directory \t Directory to use (optional, defaults to '.') \n"; print "\t -l (--labels) \t Flip the labels (-1 becomes +1) (optional)\n"; print "\t --truncate \t Truncate threshold values to increase readability\n"; *************** *** 29,32 **** --- 30,34 ---- $dirname = "."; $infofilename = ""; + $specfilename = ""; $filename = ""; $threshold = 0; *************** *** 37,40 **** --- 39,43 ---- if ( @ARGV > 0 ) { GetOptions ('i|info=s' => \$infofilename, + 's|spec=s' => \$specfilename, 't|tree=s' => \$filename, 'd|dir=s' => \$dirname, *************** *** 71,74 **** --- 74,97 ---- $graphtitle .= " | "; + + if ($specfilename eq "") { + while ($line = <INFO>) { + if ($line =~ /specFilename = (.*).*/) { + $specfilename = $1; + } + } + } + + print "Spec File: '$specfilename'\n"; + open(SPEC, "$dirname/$specfilename") || die "could not open spec file: $specFilename\n"; + + while ($line = <SPEC>) { + if ($line =~ /labels.*\((.*)\).*/) { + @labels = split(/,/, $1); + } + } + print "Labels: @labels\n"; + $numLabels = @labels; + $filename= $dirname . "/" . $filename; *************** *** 77,92 **** open(OUT,">$filename.$threshold.dot"); ! print "running atree2dot2ps.pl ".join(" ",@ARGV).". generating $filename.$threshold.{dot,ps,pdf}\n"; print OUT "digraph G \{\n"; print OUT "size=\"10,7.5\";\n"; ! print OUT "orientation=\"landscape\";\n"; print OUT "ratio=auto;\n"; print OUT "center=TRUE;\n"; - - $last_iter = 0; - while($line = <FILE>) { if($line =~ /^(\d*)\t\[([^\]]*)\] Splitter = (.*)$/) { --- 100,114 ---- open(OUT,">$filename.$threshold.dot"); ! print "Running atree2dot2ps.pl ".join(" ",@ARGV).".\n"; ! print "Generating $filename.$threshold.{dot,ps,pdf}\n"; print OUT "digraph G \{\n"; print OUT "size=\"10,7.5\";\n"; ! #print OUT "orientation=\"landscape\";\n"; ! print OUT "rotate=\"90\";\n"; print OUT "ratio=auto;\n"; print OUT "center=TRUE;\n"; $last_iter = 0; while($line = <FILE>) { if($line =~ /^(\d*)\t\[([^\]]*)\] Splitter = (.*)$/) { *************** *** 99,124 **** } if ($splitType =~ /InequalitySplitter/ && $truncatesplits) { ! $label =~ /([a-zA-Z0-9\-\s]*)\s*(<|>)\s*(-*[0-9]*(\.)?[0-9]?[0-9]?[0-9]?).*/; $var = $1; $ineq = $2; $val = $3; ! print "$type, $index, $var, $ineq, $val, $splitType\n"; $label = "$var $ineq $val" } else { ! print "$type, $index, $label, $splitType\n"; } ! } ! elsif($line =~ /^(\d*)\t\[([^\]]*)\].*p\(1\)= (.*)/) { $type = "predictor"; $iteration = $1; $index = $2; $label = $3; ! $label =~ s/(\d\.\d{3}).*/$1/; ! if($fliplabels) { ! $label = -$label; } ! print "$type, $index, $label\n"; ! } ! else { chop $line; next; --- 121,165 ---- } if ($splitType =~ /InequalitySplitter/ && $truncatesplits) { ! $label =~ /(.*)(<|>)\s*(-*[0-9]*(\.)?[0-9]?[0-9]?[0-9]?).*/; $var = $1; $ineq = $2; $val = $3; ! #print "$type, $index, $var, $ineq, $val, $splitType\n"; $label = "$var $ineq $val" } else { ! #print "line: $line\n"; ! #print "$type, $index, $label, $splitType\n"; } ! } elsif($line =~ /^(\d*)\t\[([^\]]*)\].*prediction.*= (.*)/) { $type = "predictor"; $iteration = $1; $index = $2; $label = $3; ! #print "label: $label\n"; ! $predType = $3; ! #print "predType: $predType\n"; ! if ($predType =~ /MultiPrediction/) { ! $label = ""; ! for ($i=0; $i<$numLabels; $i++) { ! $line = <FILE>; ! if ($line =~ /^.*prediction.*= (.*)/) { ! $pred = $1; ! } ! if ($fliplabels) { ! $pred = -$pred; ! } ! $label .= @labels[$i] . ": " . $pred . "\\n"; ! } ! #print "label: $label \n"; ! } else { ! $label =~ s/(\d\.\d{3}).*/$1/; ! #print "label: $label\n"; ! if($fliplabels) { ! $label = -$label; ! } } ! #print "$type, $predType, $index, $label\n"; ! } else { ! #print "Line ignored: $line"; chop $line; next; *************** *** 164,168 **** #system("dot -Tps2 $filename.$threshold.dot -o $filename.$threshold.eps"); system("dot -Tps $filename.$threshold.dot -o $filename.$threshold.ps"); ! system("ps2pdf $filename.$threshold.ps"); ! system("pstoimg -antialias -aaliastext -density 400 $filename.$threshold.ps"); --- 205,209 ---- #system("dot -Tps2 $filename.$threshold.dot -o $filename.$threshold.eps"); system("dot -Tps $filename.$threshold.dot -o $filename.$threshold.ps"); ! #system("ps2pdf $filename.$threshold.ps"); ! #system("pstoimg -antialias -aaliastext -density 400 $filename.$threshold.ps"); |