summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-05-26 13:36:57 +0200
committerAndreas Maunz <andreas@maunz.de>2011-05-26 13:36:57 +0200
commit852eef754518633f4a918aa1876ec3c4ac12ac57 (patch)
tree5b149845fb5fed265b04815f79fc2ebe0f3e8199 /lib
parent065fdeb351f68d0445b66516ccf8e7cfcc7e2a1f (diff)
parentf507227fd4efff3c8b32b2a8c8f2860af2546e3b (diff)
Merge branch 'development' into svm_matrix
Conflicts: lib/model.rb
Diffstat (limited to 'lib')
-rw-r--r--lib/dataset.rb17
-rw-r--r--lib/model.rb6
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb
index 4dc4296..fc7c263 100644
--- a/lib/dataset.rb
+++ b/lib/dataset.rb
@@ -167,16 +167,13 @@ module OpenTox
@features
end
- def feature_classes(feature, subjectid=nil)
- if Feature.find(feature, subjectid).feature_type == "classification"
- classes = []
- @data_entries.each do |c,e|
- e[feature].each { |v| classes << v.to_s }
- end
- classes.uniq.sort
- else
- nil
- end
+ # returns the accept_values of a feature, i.e. the classification domain / all possible feature values
+ # @param [String] feature the URI of the feature
+ # @return [Array] return array with strings, nil if value is not set (e.g. when feature is numeric)
+ def accept_values(feature)
+ accept_values = features[feature][OT.acceptValue]
+ accept_values.sort if accept_values
+ accept_values
end
# Detect feature type(s) in the dataset
diff --git a/lib/model.rb b/lib/model.rb
index d63eef2..7c2ef58 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -179,10 +179,12 @@ module OpenTox
load_metadata(subjectid)
case OpenTox::Feature.find(metadata[OT.dependentVariables]).feature_type
when "classification"
-
# AM: Balancing, see http://www.maunz.de/wordpress/opentox/2011/balanced-lazar
l = Array.new # larger
s = Array.new # smaller fraction
+
+ raise "no fingerprints in model" if @fingerprints.size==0
+
@fingerprints.each do |training_compound,training_features|
@activities[training_compound].each do |act|
case act.to_s
@@ -233,7 +235,7 @@ module OpenTox
@neighbors=neighbors_best
### END AM balanced predictions
- else # no balancing as before
+ else # regression case: no balancing
LOGGER.info "LAZAR: Unbalanced."
neighbors
(@prediction_algorithm.include? "svm" and params[:prop_kernel] == "true") ? props = get_props : props = nil