diff options
author | Christoph Helma <helma@in-silico.ch> | 2019-08-14 19:12:37 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2019-08-14 19:12:37 +0200 |
commit | b6ad21e340bce9ba2a2ad09fe48c656f0c2e3905 (patch) | |
tree | 6a248cfe29fb720491559e5973d8c1f1904bcc33 /scripts/cv-r-confusion-matrix.rb | |
parent | 9a217185e791d6abbe46549cd4e87c1d1a643c05 (diff) |
directory reorganization, evaluation scripts for R CVs
Diffstat (limited to 'scripts/cv-r-confusion-matrix.rb')
-rwxr-xr-x | scripts/cv-r-confusion-matrix.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/cv-r-confusion-matrix.rb b/scripts/cv-r-confusion-matrix.rb new file mode 100755 index 0000000..11a1e1b --- /dev/null +++ b/scripts/cv-r-confusion-matrix.rb @@ -0,0 +1,19 @@ +#!/usr/bin/env ruby +require 'csv' + +tp = 0 +fp = 0 +tn = 0 +fn = 0 + +rows = CSV.read(ARGV[0],headers: true,:col_sep => ";") +rows.each do |row| + a = row.to_h["Actual Outcome"].to_i + p = row.to_h["Predicted Outcome"].to_i + tp += 1 if a == 1 and p == 1 + tn += 1 if a == 0 and p == 0 + fp += 1 if a == 0 and p == 1 + fn += 1 if a == 1 and p == 0 +end + +puts "#{tp},#{fp}\n#{fn},#{tn}" |