diff options
author | Christoph Helma <helma@in-silico.ch> | 2016-05-13 13:38:24 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2016-05-13 13:38:24 +0200 |
commit | c90644211e214a50f6fdb3a936bf247f45f1f4be (patch) | |
tree | 9ae3f0b33feb55f3904c4d7a08e39567223b07aa /lib/validation-statistics.rb | |
parent | b8bb12c8a163c238d7d4387c1914e2100bb660df (diff) |
compound tests fixed
Diffstat (limited to 'lib/validation-statistics.rb')
-rw-r--r-- | lib/validation-statistics.rb | 24 |
1 files changed, 24 insertions, 0 deletions
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 |