summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2017-11-06 14:37:21 +0000
committergebele <gebele@in-silico.ch>2017-11-06 14:37:21 +0000
commit66334c4479e993fdf75535629700c84edbc7ba6c (patch)
tree94a3c20eaa4935ac8ee0763dc356cdaedd0715f9
parentf9f3faf930a9c348d81646dd9ef60e48821444a7 (diff)
various small fixes
-rw-r--r--application.rb16
-rw-r--r--views/prediction.haml27
2 files changed, 27 insertions, 16 deletions
diff --git a/application.rb b/application.rb
index 13df650..5baec21 100644
--- a/application.rb
+++ b/application.rb
@@ -50,6 +50,8 @@ get '/task/?' do
smiles = compound.smiles
task = Task.find(params[:predictions].to_s)
unless task.predictions[params[:model]].nil?
+ model = Model::Validation.find params[:model].to_s
+ type = (model.regression? ? "Regression" : "Classification")
if params[:model] == "Cramer"
prediction = task.predictions[params[:model]]
html = "<table class=\"table table-bordered single-batch\"><tr>"
@@ -67,20 +69,20 @@ get '/task/?' do
sorter = []
if prediction[:info]
sorter << {"Info" => prediction[:info]}
- if prediction[:measurements_string].kind_of?(Array)
- sorter << {"Measured activity" => "#{prediction[:measurements_string].join(";")}</br>#{prediction[:converted_measurements].join(";")}"}
+ if prediction["measurements_string"].kind_of?(Array)
+ sorter << {"Measured activity" => "#{prediction["measurements_string"].join(";")}</br>#{prediction["converted_measurements"].join(";")}"}
else
- sorter << {"Measured activity" => "#{prediction[:measurements_string]}</br>#{prediction[:converted_measurements]}"}
+ sorter << {"Measured activity" => "#{prediction["measurements_string"]}</br>#{prediction["converted_measurements"]}"}
end
end
# regression
- if prediction[:prediction_interval]
- sorter << {"Prediction" => "#{prediction[:prediction_value]}</br>#{prediction[:converted_prediction_value]}"}
- sorter << {"95% Prediction interval" => "#{prediction[:interval]}</br>#{prediction[:converted_interval]}"}
+ if prediction[:value] && type == "Regression"
+ sorter << {"Prediction" => "#{prediction["prediction_value"]}</br>#{prediction["converted_prediction_value"]}"}
+ sorter << {"95% Prediction interval" => "#{prediction[:interval]}</br>#{prediction["converted_interval"]}"}
sorter << {"Warnings" => prediction[:warnings].join("</br>")}
# classification
- elsif prediction[:probabilities]
+ elsif prediction[:value] && type == "Classification"
sorter << {"Consensus prediction" => prediction["Consensus prediction"]}
sorter << {"Consensus confidence" => prediction["Consensus confidence"]}
sorter << {"Structural alerts for mutagenicity" => prediction["Structural alerts for mutagenicity"]}
diff --git a/views/prediction.haml b/views/prediction.haml
index 872ee1e..4660112 100644
--- a/views/prediction.haml
+++ b/views/prediction.haml
@@ -63,7 +63,8 @@
=hash[:matches].blank? ? "none" : hash[:matches].join("; ")
/ check for prediction
%p
- - if prediction[:neighbors] and !prediction[:value].nil?
+ / regression
+ - if prediction[:value]
%b.title= ("Lazar #{@models[i].endpoint.gsub('_', ' ').downcase} (#{@models[i].species}):" if sa_prediction)
%p
/ check for database hit
@@ -118,16 +119,24 @@
=prediction[:warnings].join("</br>")
- else
- %p
- if !prediction[:info].blank?
- :plain
- This compound was part of the training dataset. <i>All</i> information </br>
- from this compound was removed from the training data before the </br>
- prediction, to obtain unbiased results.
+ %p
+ :plain
+ This compound was part of the training dataset. <i>All</i> information </br>
+ from this compound was removed from the training data before the </br>
+ prediction, to obtain unbiased results.
+ %p
+ %b Measured activity:
+ %br
+ - if prediction[:measurements].is_a?(Array)
+ = (type == "Regression") ? prediction[:measurements].collect{|value| "#{value.delog10.signif(3)} (#{unit})</br>#{@compound.mmol_to_mg(value.delog10).signif(3)} #{unit =~ /mmol\/L/ ? "(mg/L)" : "(mg/kg_bw/day)"}"}.join("</br>") : prediction[:measurements].join(", ")
+ - else
+ = (type == "Regression") ? "#{prediction[:measurements].delog10.signif(3)} (#{unit})</br>#{@compound.mmol_to_mg(prediction[:measurements].delog10).signif(3)} #{(unit =~ /\b(mmol\/L)\b/) ? "(mg/L)" : "(mg/kg_bw/day)"}" : prediction[:measurements]
- if !prediction[:warnings].blank?
- %b Warnings:
- %br
- =prediction[:warnings].join("</br>")
+ %p
+ %b Warnings:
+ %br
+ =prediction[:warnings].join("</br>")
/ show Cramer rules if checked
- if @toxtree == true