diff options
author | Christoph Helma <helma@in-silico.ch> | 2019-10-21 17:29:52 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2019-10-21 17:29:52 +0200 |
commit | 93f2fb17788b9d02b00935e0d1be7cd1d81ff555 (patch) | |
tree | 95ea869bf48bd41bb0d6d341e6cee7f3e01d2c81 /scripts | |
parent | 1035124b854e21998d3fd9de4935780a19a2d3d3 (diff) |
mustache preprocessing
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/confusion-matrix2table.rb | 10 | ||||
-rwxr-xr-x | scripts/cv-tensorflow-confusion-matrix.rb | 2 | ||||
-rwxr-xr-x | scripts/results.rb | 36 | ||||
-rwxr-xr-x | scripts/summaries2table.rb | 19 |
4 files changed, 66 insertions, 1 deletions
diff --git a/scripts/confusion-matrix2table.rb b/scripts/confusion-matrix2table.rb new file mode 100755 index 0000000..ccb4817 --- /dev/null +++ b/scripts/confusion-matrix2table.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +mat = [] +File.readlines(ARGV[0]).each do |l| + mat << l.chomp.split(",") +end +puts ",,Predictions," +puts ",,mutagenic,non-mutagenic" +puts "Measurements,mutagenic,#{mat[0][0]},#{mat[0][1]}" +puts ",non-mutagenic,#{mat[1][0]},#{mat[1][1]}" diff --git a/scripts/cv-tensorflow-confusion-matrix.rb b/scripts/cv-tensorflow-confusion-matrix.rb index 067519b..2b0ee58 100755 --- a/scripts/cv-tensorflow-confusion-matrix.rb +++ b/scripts/cv-tensorflow-confusion-matrix.rb @@ -7,7 +7,7 @@ tn = 0 fn = 0 pred = CSV.read(ARGV[0],headers: true,:col_sep => ",") -act = CSV.read(File.join(File.dirname(ARGV[0]),"GenoTox-database.csv"),headers: true,:col_sep => ",") +act = CSV.read(File.join("data","GenoTox-database.csv"),headers: true,:col_sep => ",") pred.each_with_index do |row,i| diff --git a/scripts/results.rb b/scripts/results.rb new file mode 100755 index 0000000..1a36278 --- /dev/null +++ b/scripts/results.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'json' + +result = {} +ARGV.each do |f| + fname = File.basename(f,".json") + program,algo = fname.split('-') + case program + when "tensorflow" + algo == "all" ? algo = "without feature selection" : algo = "with feature selection" + when "lazar" + algo = "high-confidence" if algo == "high" + if algo == "padel" + algo = "PaDEL" + fname.match("high") ? algo += " high-confidence" : algo += " all" + end + end + result[program] ||= {} + result[program][algo] = JSON.parse(File.read(f)).collect{|k,v| [k,v.round(2)]}.to_h +end + +out = {:programs => []} +result.keys.each do |prog| + out[:programs] << {:name => prog, :algos => []} + result[prog].keys.each do |algo| + r = result[prog][algo].dup + result[prog][algo].each do |k,v| + r[k+"_perc"] = (v*100).round + end + r[:name] = algo + r[:abbrev] = prog+"-"+algo + out[:programs].last[:algos] << r + end +end + +puts out.to_json diff --git a/scripts/summaries2table.rb b/scripts/summaries2table.rb new file mode 100755 index 0000000..5470b26 --- /dev/null +++ b/scripts/summaries2table.rb @@ -0,0 +1,19 @@ +#!/usr/bin/env ruby +require 'json' + +results = {} + +ARGV.each do |f| + results[File.basename(f,".json")] = JSON.parse(File.read(f)) +end + +print "," +puts results.keys.collect{|k| k.sub("tensorflow","TF")}.join(",") +["accuracy","true_positive_rate","true_negative_rate","positive_predictive_value","negative_predictive_value"].each do |m| + line = [m.gsub("_"," ")] + results.each do |k,v| + line << v[m].round(2) + end + puts line.join(",") +end + |