From 9eb9fd8ab470d6c44c70e0af0808204bdda2b161 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 17 Mar 2016 11:28:18 +0000 Subject: snapshot, works only with png plots --- application.rb | 12 ++++++++++++ views/model_details.haml | 24 ++++++++++++------------ views/style.scss | 9 +++++++++ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/application.rb b/application.rb index fc7e415..a4dc7c4 100644 --- a/application.rb +++ b/application.rb @@ -31,6 +31,18 @@ end get '/predict/modeldetails/:model' do model = OpenTox::Model::Prediction.find params[:model] + crossvalidations = model.crossvalidations + confidence_plots = crossvalidations.collect{|cv| [cv.id, cv.confidence_plot]} + confidence_plots.each do |confp| + File.open(File.join('public', "confp#{confp[0]}.png"), 'w'){|file| file.write(confp[1])} unless File.exists? File.join('public', "confp#{confp[0]}.png") + end + if model.regression? + correlation_plots = crossvalidations.collect{|cv| [cv.id, cv.correlation_plot]} + correlation_plots.each do |corrp| + File.open(File.join('public', "corrp#{corrp[0]}.png"), 'w'){|file| file.write(corrp[1])} unless File.exists? File.join('public', "corrp#{corrp[0]}.png") + end + end + return haml :model_details, :layout=> false, :locals => {:model => model} end diff --git a/views/model_details.haml b/views/model_details.haml index e5886e7..04cc0f0 100644 --- a/views/model_details.haml +++ b/views/model_details.haml @@ -97,10 +97,9 @@ Source: -#= "Confusion Matrix:\t" -#= cv.confusion_matrix %br - -#%p - = "Confidence plot:" - -#%p{:id=>"confp#{cv.id}", :style=>"transform:scale(0.5);margin-left:-30%;margin-top:-30%;padding:0;"} - = cv.confidence_plot + = "Confidence plot:" + %p.plot + %img{:src=>"confp#{cv.id}.png"} - if model.regression? %br = "Root mean squared error:\t" @@ -117,12 +116,13 @@ Source: %br = "R square:\t" = cv.r_squared.round(3) if cv.r_squared - -#%p - = "Correlation plot" - -#%p{:id=>"corrp#{cv.id}", :style=>"transform:scale(0.5);margin-left:-30%;margin-top:-30%;margin-bottom:0;padding:0;"} - =cv.correlation_plot - -#%p - = "Confidence plot:" - -#%p{:id=>"confp#{cv.id}", :style=>"transform:scale(0.5);margin-left:-30%;margin-top:-30%;margin-bottom:0;padding:0;"} - = cv.confidence_plot + %br + = "Confidence plot:" + %p.plot + %img{:src=>"/confp#{cv.id}.png"} + %br + = "Correlation plot" + %p.plot + %img{:src=>"/corrp#{cv.id}.png"} + %br diff --git a/views/style.scss b/views/style.scss index 9a3c9df..a0502b5 100644 --- a/views/style.scss +++ b/views/style.scss @@ -16,3 +16,12 @@ h4.head-back, h5.head-back{ height: 5em; } } +img { + max-width: 100%; + max-height: 100%; +} + +.plot { + height: 300px; + width: 300px; +} -- cgit v1.2.3