summaryrefslogtreecommitdiff
path: root/lib/Kratos
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-04-06 11:52:59 +0200
committerDaniel Friesel <derf@finalrewind.org>2017-04-06 11:52:59 +0200
commitc1e240e1926b2912591bbef723f7a825100587fd (patch)
tree69852f5211ef145a6af6c83979363c66140b1903 /lib/Kratos
parent1db2484270d937a4f2d80c24f88c18f7aaecc545 (diff)
define, optimize, assess and plot arg-dependent functions
Diffstat (limited to 'lib/Kratos')
-rw-r--r--lib/Kratos/DFADriver.pm58
1 files changed, 55 insertions, 3 deletions
diff --git a/lib/Kratos/DFADriver.pm b/lib/Kratos/DFADriver.pm
index b894248..b393415 100644
--- a/lib/Kratos/DFADriver.pm
+++ b/lib/Kratos/DFADriver.pm
@@ -139,8 +139,11 @@ sub log {
}
sub assess_fits {
- my ( $self, $hash, $param ) = @_;
- my $errmap = $hash->{fit_guess}{$param};
+ my ( $self, $hash, $param, $funtype ) = @_;
+
+ $funtype //= 'fit_guess';
+
+ my $errmap = $hash->{$funtype}{$param};
my @errors = map { [ $_, $errmap->{$_} ] } keys %{$errmap};
@errors = sort { $a->[1]{rmsd} <=> $b->[1]{rmsd} } @errors;
@@ -320,6 +323,7 @@ sub printf_parameterized {
my $std_ind_arg = $hash->{std_arg};
my $std_ind_param = $hash->{std_param};
my $std_ind_trace = $hash->{std_trace};
+ my $std_by_arg = $hash->{std_by_arg} // {};
my $std_by_param = $hash->{std_by_param};
my $std_by_trace = $hash->{std_by_trace} // {};
my $arg_ratio;
@@ -400,12 +404,32 @@ sub printf_parameterized {
$status = 'depends';
}
if ($fline) {
- printf( " %s: %s on %s (%.2f / %.2f = %.3f%s)\n",
+ printf( " %s: %s on global %s (%.2f / %.2f = %.3f%s)\n",
$key, $status, $param, $std_ind_param, $std_this, $ratio,
$fline );
}
}
+ for my $arg ( sort keys %{$std_by_arg} ) {
+ my $std_this = $std_by_arg->{$arg};
+ my $ratio = $std_ind_arg / $std_this;
+ my $status = 'does not depend';
+ my $fline = q{};
+ if ( $ratio < 0.6 ) {
+ $status = 'might depend';
+ $fline = q{, probably };
+ $fline .= join( ' or ', $self->assess_fits( $hash, $arg, 'arg_fit_guess' ) );
+ }
+ if ( $ratio < 0.3 ) {
+ $status = 'depends';
+ }
+ if ($fline) {
+ printf( " %s: %s on local %s (%.2f / %.2f = %.3f%s)\n",
+ $key, $status, $arg, $std_ind_arg, $std_this, $ratio,
+ $fline );
+ }
+ }
+
for my $transition ( sort keys %{$std_by_trace} ) {
my $std_this = $std_by_trace->{$transition};
my $ratio = $std_ind_trace / $std_this;
@@ -467,6 +491,34 @@ sub printf_fit {
$hash->{param_mean_goodness}{rmsd}
);
}
+ if ( exists $hash->{arg_function}{user} ) {
+ if ( exists $hash->{arg_function}{user}{error} ) {
+ printf( " user-specifed %s argfunction could not be fitted: %s\n",
+ $key, $hash->{arg_function}{user}{error} );
+ }
+ else {
+ printf(
+ " user-specifed %s argfunction fit error: %.2f%% / %.f %s\n",
+ $key,
+ $hash->{arg_function}{user}{fit}{smape} // -1,
+ $hash->{arg_function}{user}{fit}{mae}, $unit
+ );
+ }
+ }
+ if ( exists $hash->{arg_function}{estimate} ) {
+ if ( exists $hash->{arg_function}{estimate}{error} ) {
+ printf( " estimated %s argfunction could not be fitted: %s\n",
+ $key, $hash->{arg_function}{estimate}{error} );
+ }
+ else {
+ printf(
+ " estimated %s argfunction fit error: %.2f%% / %.f %s\n",
+ $key,
+ $hash->{arg_function}{estimate}{fit}{smape} // -1,
+ $hash->{arg_function}{estimate}{fit}{mae}, $unit
+ );
+ }
+ }
if ( exists $hash->{arg_mean_goodness} ) {
printf(
" %s: arg mean/ssr-fit LUT error: %.2f%% / %.f %s / %.f\n",