Fixed $PRIOR support and bugfix in shrinkage results handling
[PsN.git] / bin / crossval
blobb62177f622c20301653254ab105e562e3f44e21d
1 #!/usr/local/bin/perl
3 use FindBin qw($Bin);
4 use lib "$Bin/../lib";
6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
9 use PsN;
10 use model;
11 use tool::xv;
12 use strict;
13 use debug;
14 use ui;
15 use Getopt::Long;
16 use common_options;
18 my $cmd_line = $0 . " " . join( " ", @ARGV );
20 ## Configure the command line parsing
21 Getopt::Long::config("auto_abbrev");
23 ## Declare the options
24 my %options;
26 my %required_options = ( "fractions:i"=>'' );
27 my %optional_options = ( );
29 my $res = GetOptions( \%options,
30 @common_options::get_opt_strings,
31 keys(%required_options),
32 keys(%optional_options) );
34 exit unless $res;
36 debug -> level( $options{'debug'} );
37 debug -> package( $options{'debug_package'} );
38 debug -> subroutine( $options{'debug_subroutine'} );
39 debug -> warn_with_trace( $options{'warn_with_trace'} );
41 my $eval_string = common_options::model_parameters(\%options);
43 my $model = model -> new ( eval( $eval_string ),
44 filename => @ARGV[0],
45 debug => $options{'debug'},
46 ignore_missing_output_files => 1 );
48 my $xv = tool::xv_step -> new( nr_validation_groups => $options{'fractions'},
49 models => [$model],
50 subtool_arguments => { modelfit => { eval( $common_options::parameters ) } },
51 post_analyze => \&harvest_ofv,
54 $xv -> run;
57 sub harvest_ofv{
58 my $xv_object = shift;
60 open XV_REPORT, '>', "xv_result.txt";
61 print XV_REPORT "Prediction model OFV's\tEstimation model OFV's\n";
62 for( my $i = 0; $i <= $#{$xv_object -> prediction_models}; $i++ ){
63 print XV_REPORT $xv_object -> prediction_models -> [$i] -> outputs -> [0] -> ofv -> [0][0], "\t";
64 print XV_REPORT $xv_object -> estimation_models -> [$i] -> outputs -> [0] -> ofv -> [0][0], "\n";
67 close XV_REPORT;