From f13763a8505ad997739b65d7cfcd804411ff9c77 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 26 May 2011 10:56:31 +0200 Subject: unify access to classification feature domain, replace methode feature_values with accept_values --- lib/dataset.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3 From f507227fd4efff3c8b32b2a8c8f2860af2546e3b Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Thu, 26 May 2011 13:11:32 +0200 Subject: Hotfix: Switch to balanced mode. --- lib/model.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/model.rb b/lib/model.rb index 139aed8..14471cc 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -176,11 +176,15 @@ module OpenTox return @prediction_dataset if database_activity(subjectid) - - if metadata[RDF.type] == [OTA.ClassificationLazySingleTarget] + 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 @@ -231,6 +235,7 @@ module OpenTox ### END AM balanced predictions else # regression case: no balancing + LOGGER.info "LAZAR: Unbalanced." neighbors prediction = eval("#{@prediction_algorithm}(@neighbors,{:similarity_algorithm => @similarity_algorithm, :p_values => @p_values})") end -- cgit v1.2.3