diff options
-rw-r--r-- | lib/dataset.rb | 29 | ||||
-rw-r--r-- | lib/environment.rb | 2 | ||||
-rw-r--r-- | lib/features.rb | 6 | ||||
-rw-r--r-- | lib/model.rb | 4 | ||||
-rw-r--r-- | lib/templates/config.yaml | 5 |
5 files changed, 35 insertions, 11 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb index fc4502a..af72403 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -86,7 +86,7 @@ module OpenTox def get_predicted_class(compound, feature) v = get_value(compound, feature) if v.is_a?(Hash) - k = v.keys.grep("classification") + k = v.keys.grep(/classification/).first unless k.empty? #if v.has_key?(:classification) return v[k] @@ -105,14 +105,37 @@ module OpenTox end end + # returns regression value + def get_predicted_regression(compound, feature) + v = get_value(compound, feature) + if v.is_a?(Hash) + k = v.keys.grep(/regression/).first + unless k.empty? + return v[k] + else + return "no regression key" + end + elsif v.is_a?(Array) + raise "predicted regression value is an array\n"+ + "value "+v.to_s+"\n"+ + "value-class "+v.class.to_s+"\n"+ + "dataset "+@uri.to_s+"\n"+ + "compound "+compound.to_s+"\n"+ + "feature "+feature.to_s+"\n" + else + return v + end + end + # returns prediction confidence if available def get_prediction_confidence(compound, feature) v = get_value(compound, feature) if v.is_a?(Hash) - k = v.keys.grep("confidence") + k = v.keys.grep(/confidence/).first unless k.empty? #if v.has_key?(:confidence) - return v[:confidence].abs + return v[k].abs + #return v["http://ot-dev.in-silico.ch/model/lazar#confidence"].abs else # PENDING: return nil isntead of raising an exception raise "no confidence key" diff --git a/lib/environment.rb b/lib/environment.rb index e37463b..abc7287 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -41,7 +41,7 @@ if @@config[:database] end end -# mail for error messages +# load mail settings for error messages load File.join config_dir,"mail.rb" if File.exists?(File.join config_dir,"mail.rb") # hack: store sinatra in global var to make url_for and halt methods accessible diff --git a/lib/features.rb b/lib/features.rb index c56f3e4..0fa1cf0 100644 --- a/lib/features.rb +++ b/lib/features.rb @@ -1,3 +1,7 @@ +# CH: should go into validation service +# - not a complete OT object +# - only used twice +# - what about ./validation/validation/validation_service.rb:241: value = OpenTox::Feature.new(:uri => a.uri).value(prediction_feature).to_s module OpenTox module Feature @@ -12,4 +16,4 @@ module OpenTox end end -end
\ No newline at end of file +end diff --git a/lib/model.rb b/lib/model.rb index f2d7ba5..b6cef46 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -61,8 +61,10 @@ module OpenTox def classification? #HACK replace with request to ontology server - if @title =~ /classification/ + if @title =~ /(?i)classification/ return true + elsif @title =~ /(?i)regression/ + return false elsif @uri =~/ntua/ and @title =~ /mlr/ return false elsif @uri =~/tu-muenchen/ and @title =~ /regression|M5P|GaussP/ diff --git a/lib/templates/config.yaml b/lib/templates/config.yaml index 3b97983..dba0bf3 100644 --- a/lib/templates/config.yaml +++ b/lib/templates/config.yaml @@ -43,23 +43,18 @@ - "text/plain" opentox-dataset: - "application/x-yaml" - - "text/x-yaml" - "application/rdf+xml" opentox-algorithm: - "application/x-yaml" - - "text/x-yaml" - "application/rdf+xml" opentox-model: - "application/x-yaml" - - "text/x-yaml" - "application/rdf+xml" opentox-task: - "application/x-yaml" - - "text/x-yaml" - "application/rdf+xml" opentox-validation: - "application/x-yaml" - - "text/x-yaml" - "application/rdf+xml" # Timeouts: |