summaryrefslogtreecommitdiff
path: root/lib/dataset.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2010-07-02 12:33:06 +0200
committerChristoph Helma <helma@in-silico.ch>2010-07-02 12:33:06 +0200
commit0bbfb66685b9c647bc51dab432a63cb61114a697 (patch)
tree0e923e9247f49b3b38adc476bc764c0b8057185d /lib/dataset.rb
parentc024c22038eb2eb16d946132eca908412515c656 (diff)
parent818e97b33178f5fe0a0b02b6db26e0b1bcb4a7ec (diff)
return of confidence, classification and regression values from prediction datasets fixed
Diffstat (limited to 'lib/dataset.rb')
-rw-r--r--lib/dataset.rb29
1 files changed, 26 insertions, 3 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"