From c90644211e214a50f6fdb3a936bf247f45f1f4be Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 13 May 2016 13:38:24 +0200 Subject: compound tests fixed --- lib/validation-statistics.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/validation-statistics.rb') diff --git a/lib/validation-statistics.rb b/lib/validation-statistics.rb index 0079bae..2d6b56e 100644 --- a/lib/validation-statistics.rb +++ b/lib/validation-statistics.rb @@ -96,5 +96,29 @@ module OpenTox :finished_at => Time.now } end + + end + + module Plot + + def plot_id + tmpfile = "/tmp/#{id.to_s}_correlation.png" + x = [] + y = [] + predictions.each do |sid,p| + x << p["value"] + y << p["measured"].median + end + R.assign "measurement", x + R.assign "prediction", y + R.eval "all = c(measurement,prediction)" + R.eval "range = c(min(all), max(all))" + R.eval "image = qplot(prediction,measurement,main='',asp=1,xlim=range, ylim=range)" + R.eval "image = image + geom_abline(intercept=0, slope=1)" + R.eval "ggsave(file='#{tmpfile}', plot=image)" + file = Mongo::Grid::File.new(File.read(tmpfile), :filename => "#{self.id.to_s}_correlation_plot.png") + plot_id = $gridfs.insert_one(file) + plot_id + end end end -- cgit v1.2.3