diff options
author | Christoph Helma <helma@in-silico.ch> | 2019-10-21 20:29:12 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2019-10-21 20:29:12 +0200 |
commit | 2e03df94681951a62229b76b52370da094aa1ec6 (patch) | |
tree | a1bedd275c3ffab65c49f4eefec91bf6a0768d09 /scripts | |
parent | b1e01382e0580676d3686195f9897a60a2ffee1d (diff) |
Results section
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/confusion-matrix-summary.rb | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/scripts/confusion-matrix-summary.rb b/scripts/confusion-matrix-summary.rb index a9742f7..e0adf4e 100755 --- a/scripts/confusion-matrix-summary.rb +++ b/scripts/confusion-matrix-summary.rb @@ -1,19 +1,33 @@ #!/usr/bin/env ruby require 'csv' -require 'json' +require 'yaml' -csv = CSV.read(ARGV[0],headers: false,:col_sep => ",") -tp = csv[0][0].to_f -fp = csv[0][1].to_f -fn = csv[1][0].to_f -tn = csv[1][1].to_f +results = {} +ARGV.each do |f| + csv = CSV.read(f,headers: false,:col_sep => ",") + tp = csv[0][0].to_f + fp = csv[0][1].to_f + fn = csv[1][0].to_f + tn = csv[1][1].to_f -result = { - :accuracy => (tp+tn)/(tp+fp+tn+fn), - :true_positive_rate => tp/(tp+fn), - :true_negative_rate => tn/(tn+fp), - :positive_predictive_value => tp/(tp+fp), - :negative_predictive_value => tn/(tn+fn), -} + result = { + :tp => tp.to_i, + :fp => fp.to_i, + :tn => tn.to_i, + :fn => fn.to_i, + :n => (tp+fp+tn+fn).to_i, + :acc => ((tp+tn)/(tp+fp+tn+fn)).round(2), + :tpr => (tp/(tp+fn)).round(2), + :tnr => (tn/(tn+fp)).round(2), + :ppv => (tp/(tp+fp)).round(2), + :npv => (tn/(tn+fn)).round(2), + :acc_perc => (100*(tp+tn)/(tp+fp+tn+fn)).round(0), + :tpr_perc => (100*tp/(tp+fn)).round(0), + :tnr_perc => (100*tn/(tn+fp)).round(0), + :ppv_perc => (100*tp/(tp+fp)).round(0), + :npv_perc => (100*tn/(tn+fn)).round(0), + } + results[File.basename(f,".csv")] = result +end -puts result.to_json +puts results.to_yaml |