summaryrefslogtreecommitdiff
path: root/scripts/cv-r-confusion-matrix.rb
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cv-r-confusion-matrix.rb')
-rwxr-xr-xscripts/cv-r-confusion-matrix.rb19
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}"