summaryrefslogtreecommitdiff
path: root/scripts/crossvalidation-table.rb
blob: 1ea58945b4baf1d2b6d0636668a8ef8f7b5f1850 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby
require_relative '../../lazar/lib/lazar'
include OpenTox

id = File.open(ARGV[0]).readlines.sample.chomp # random cv
csv_file = "data/training_log10-cv.csv"
cv = Validation::RegressionCrossValidation.find id
data = []
cv.predictions.each do |cid,p|
  smi = Compound.find(cid).smiles
  warnings = "F"
  warnings = "T" if p["warnings"] and !p["warnings"].empty?
	if p["prediction_interval"]
		data << [smi,p["value"],p["measurements"].median,p["prediction_interval"][0],p["prediction_interval"][1],warnings]
	else
		data << [smi,p["value"],p["measurements"].median,nil,nil,warnings]
  end
end

data.sort!{|a,b| a[1] <=> b[1]}

CSV.open(csv_file,"w+") do |csv|
  csv << ["SMILES","LOAEL_measured_median","LOAEL_predicted","Prediction_interval_low","Prediction_interval_high","Warnings"]
  data.each{|r| csv << r}
end