summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2010-07-02 17:50:43 +0200
committerChristoph Helma <helma@in-silico.ch>2010-07-02 17:50:43 +0200
commit6b8b0a161f492f15c33d4f18e50b604e0fd547bc (patch)
tree09ac1eb87447abfa69ce446eef5ad930d4b2dc91
parent258e55e5cbd1355a30dad6bbe2a2638609db9a18 (diff)
Initial regression validation display
-rw-r--r--application.rb14
-rw-r--r--model.rb39
-rwxr-xr-xpublic/javascripts/toxcreate.js2
-rw-r--r--views/classification_validation.haml (renamed from views/model_validation.haml)4
-rw-r--r--views/model.haml7
-rw-r--r--views/regression_validation.haml19
6 files changed, 58 insertions, 27 deletions
diff --git a/application.rb b/application.rb
index 40aabef..735f388 100644
--- a/application.rb
+++ b/application.rb
@@ -53,18 +53,20 @@ get '/model/:id/:view/?' do
model = ToxCreateModel.get(params[:id])
model.process
- begin
+ #begin
case params[:view]
when "model"
haml :model, :locals=>{:model=>model}, :layout => false
- when "validation"
- haml :model_validation, :locals=>{:model=>model}, :layout => false
+ when "classification_validation"
+ haml :classification_validation, :locals=>{:model=>model}, :layout => false
+ when "regression_validation"
+ haml :regression_validation, :locals=>{:model=>model}, :layout => false
else
return "render error"
end
- rescue
- return "unable to render model"
- end
+ #rescue
+ # return "unable to render model"
+ #end
end
get '/predict/?' do
diff --git a/model.rb b/model.rb
index e35507b..6e2441a 100644
--- a/model.rb
+++ b/model.rb
@@ -11,6 +11,7 @@ class ToxCreateModel
property :validation_report_uri, String, :length => 255
property :warnings, Text, :length => 2**32-1
property :nr_compounds, Integer
+ property :type, String
property :created_at, DateTime
def status
@@ -57,22 +58,7 @@ class ToxCreateModel
end
end
- def type
- lazar = RestClient.get(@uri, :accept => "application/x-yaml").body
- #LOGGER.debug lazar
- lazar = YAML.load(lazar)
- #LOGGER.debug lazar.inspect
- case lazar.dependentVariables
- when /classification/
- return "classification"
- when /regression/
- return "regression"
- else
- return "unknown"
- end
- end
-
- def validation
+ def classification_validation
begin
uri = File.join(@validation_uri, 'statistics')
yaml = RestClient.get(uri).body
@@ -109,11 +95,32 @@ class ToxCreateModel
end
end
+ def regression_validation
+ begin
+ uri = File.join(@validation_uri, 'statistics')
+ yaml = RestClient.get(uri).body
+ v = YAML.load(yaml)
+ rescue
+ "Service offline"
+ end
+ end
+
def process
+
if !@uri and status == "Completed"
@uri = RestClient.get(File.join(@task_uri, 'resultURI')).body
+ lazar = YAML.load(RestClient.get(@uri, :accept => "application/x-yaml").body)
+ case lazar.dependentVariables
+ when /classification/
+ @type = "classification"
+ when /regression/
+ @type = "regression"
+ else
+ @type = "unknown"
+ end
save
end
+
if !@validation_uri and validation_status == "Completed"
begin
@validation_uri = RestClient.get(File.join(@validation_task_uri, 'resultURI')).body
diff --git a/public/javascripts/toxcreate.js b/public/javascripts/toxcreate.js
index b1555c6..cd2efa2 100755
--- a/public/javascripts/toxcreate.js
+++ b/public/javascripts/toxcreate.js
@@ -68,7 +68,7 @@ $(function() {
},
success: function(data) {
if (view == "model") $("div#model_" + id).html(data);
- if (view == "validation") $("dl#model_validation_" + id).html(data);
+ if (view ~= /validation/) $("dl#model_validation_" + id).html(data);
},
error: function(data) {
//alert("loadModel error");
diff --git a/views/model_validation.haml b/views/classification_validation.haml
index 8f5e3ce..6d18d09 100644
--- a/views/model_validation.haml
+++ b/views/classification_validation.haml
@@ -6,8 +6,8 @@
%a{:href => model.validation_report_uri, :target => "_blank"} (more details)
%dd
- if model.validation_uri
- - v = model.validation
- - if v == "Service not available"
+ - v = model.classification_validation
+ - if v == "Service offline"
= v
- else
%dl
diff --git a/views/model.haml b/views/model.haml
index e336de6..234dcc6 100644
--- a/views/model.haml
+++ b/views/model.haml
@@ -32,7 +32,6 @@
%dt Algorithm:
%dd
%a{:href => "http://www.in-silico.de/articles/modi020905.pdf"} #{File.basename model.algorithm}
- -# %a{:href => model.algorithm} RDF/XML
%dt Type:
%dd= model.type
%dt Descriptors:
@@ -58,5 +57,9 @@
,
%a{:href => "#{model.uri}.yaml"} YAML
%em (experts, models cannot be exported in Excel)
- = haml :model_validation, :locals=>{:model=>model}, :layout => false
+ - case model.type
+ - when "classification"
+ = haml :classification_validation, :locals=>{:model=>model}, :layout => false
+ -when "regression"
+ = haml :regression_validation, :locals=>{:model=>model}, :layout => false
diff --git a/views/regression_validation.haml b/views/regression_validation.haml
new file mode 100644
index 0000000..983599b
--- /dev/null
+++ b/views/regression_validation.haml
@@ -0,0 +1,19 @@
+%dl{:id => "model_validation_#{model.id}"}
+ %dt
+ Validation:
+ %input{ :id => "model_validation_#{model.id}", :type => "hidden", :value => "#{model.validation_status}", :class => "model_validation" }
+ - if model.validation_report_uri
+ %a{:href => model.validation_report_uri, :target => "_blank"} (more details)
+ %dd
+ - if model.validation_uri
+ - v = model.regression_validation
+ - if v == "Service offline"
+ = v
+ - else
+ %dl
+ %dt Number of predictions:
+ %dd= v[:n]
+ %p= v.inspect
+ - else
+ = image_tag("/snake_transparent.gif") if model.validation_status == "Running"
+ %a{:href => model.validation_task_uri} #{model.validation_status}