#!/usr/local/bin/perl

# run_cla_mlcnb
# by Johann Petrak (OeFAI)
#
# no resubst error since mlcnb doesnt show this on its output

$pgmversion = '$Revision: 3.0 $';
$pgmdate    = '$Date: 2002/06/30 19:05:19 $';
$rcsid      = '$Id: run_cla_mlcnb,v 3.0 2002/06/30 19:05:19 johann Exp $';
$dummy      = '$';   # just here to satisfy the dumb emacs fontifyer

use vars qw($pgmname $pgmpath $trainargs $args $debug
	    $testargs  $predfile $filestem $la);
use Getopt::Long;
use File::Basename;
$pgmname = $0;
$pgmpath = dirname($pgmname);
push(@INC,$pgmpath);
require run_lib;

beginLA("mlcnb",$pgmversion); 

startCMD("$la -train $filestem $filestem.$la.model $args $trainargs");
while (defined($_=getLine())) {
  if (/Model Complexity : ([0-9]+)/) {
    $k{"Size"} = $1;
  }
}
$k{"Traintime"} = stopCMD();

startCMD("$la -test $filestem $filestem.$la.model $predfile $args $testargs");
while (defined($_=getLine())) {
  if (/^Error:\s+([0-9\.]+)/) {
    $k{"Error"} = $1 / 100.0;
  }
}
$k{"Testtime"} = stopCMD();

rmFile("$filestem.$la.model");

endLA();
