From 6b45e9720286d21aee1de6e381d9200002812491 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 30 May 2017 15:58:32 +0200 Subject: calculate Spearman rank-order correlation coefficient --- lib/Kratos/DFADriver.pm | 5 +++++ lib/dfatool.py | 8 ++++++++ 2 files changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/Kratos/DFADriver.pm b/lib/Kratos/DFADriver.pm index f238ba4..ade6067 100644 --- a/lib/Kratos/DFADriver.pm +++ b/lib/Kratos/DFADriver.pm @@ -342,6 +342,7 @@ sub printf_parameterized { 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 $r_by_param = $hash->{spearmanr_by_param} // {}; my $arg_ratio; my $param_ratio; my $trace_ratio; @@ -423,6 +424,10 @@ sub printf_parameterized { $key, $status, $param, $std_ind_param, $std_this, $ratio, $fline ); } + if (exists $r_by_param->{$param}) { + printf(" %s: spearman_r for global %s is %.3f (p = %.3f)\n", + $key, $param, $r_by_param->{$param}, -1); + } } for my $arg ( sort keys %{$std_by_arg} ) { diff --git a/lib/dfatool.py b/lib/dfatool.py index 66be4fd..fcbac94 100755 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -23,6 +23,14 @@ def is_numeric(n): except ValueError: return False +def float_or_nan(n): + if n == None: + return np.nan + try: + return float(n) + except ValueError: + return np.nan + def append_if_set(aggregate, data, key): if key in data: aggregate.append(data[key]) -- cgit v1.2.3