diff options
Diffstat (limited to 'scripts/cv-tensorflow-confusion-matrix.rb')
-rwxr-xr-x | scripts/cv-tensorflow-confusion-matrix.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/scripts/cv-tensorflow-confusion-matrix.rb b/scripts/cv-tensorflow-confusion-matrix.rb index 2b0ee58..fba5c49 100755 --- a/scripts/cv-tensorflow-confusion-matrix.rb +++ b/scripts/cv-tensorflow-confusion-matrix.rb @@ -7,17 +7,30 @@ tn = 0 fn = 0 pred = CSV.read(ARGV[0],headers: true,:col_sep => ",") -act = CSV.read(File.join("data","GenoTox-database.csv"),headers: true,:col_sep => ",") +act = CSV.read(File.join("data","mutagenicity.csv"),headers: true,:col_sep => ",") -pred.each_with_index do |row,i| +data = {} +pred.each do |row| row[1].to_f < 0.5 ? p = 0 : p = 1 - a = act[i].to_h["GENO.Outcome"].to_i + data[row[0]] =[p] +end + +act.each do |row| + if row[1] == "mutagenic" + a = 1 + elsif row[1] == "non-mutagenic" + a = 0 + end + data[row[0]] << a if data[row[0]] +end + +data.each do |smi,a| - 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 + tp += 1 if a[0] == 1 and a[1] == 1 + tn += 1 if a[0] == 0 and a[1] == 0 + fp += 1 if a[0] == 0 and a[1] == 1 + fn += 1 if a[0] == 1 and a[1] == 0 end |