diff options
Diffstat (limited to 'lib/validation-statistics.rb')
-rw-r--r-- | lib/validation-statistics.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/validation-statistics.rb b/lib/validation-statistics.rb index 156353a..e61543b 100644 --- a/lib/validation-statistics.rb +++ b/lib/validation-statistics.rb @@ -83,7 +83,7 @@ module OpenTox end R.assign "measurement", x R.assign "prediction", y - R.eval "r <- cor(measurement,prediction,use='complete')" + R.eval "r <- cor(measurement,prediction,use='pairwise')" r = R.eval("r").to_ruby mae = mae/predictions.size @@ -99,11 +99,7 @@ module OpenTox } end - end - - module Plot - - def plot_id + def self.correlation_plot id, predictions tmpfile = "/tmp/#{id.to_s}_correlation.png" x = [] y = [] @@ -115,10 +111,11 @@ module OpenTox 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)" + # TODO units + R.eval "image = qplot(prediction,measurement,main='',xlab='Prediction',ylab='Measurement',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") + file = Mongo::Grid::File.new(File.read(tmpfile), :filename => "#{id.to_s}_correlation_plot.png") plot_id = $gridfs.insert_one(file) plot_id end |