summaryrefslogtreecommitdiff
path: root/scripts/confusion-matrix-summary.rb
blob: a9742f71cf1decdb8f7ea7105dfbbae3fb3bda34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env ruby
require 'csv'
require 'json'

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

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),
}

puts result.to_json