#!/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