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 From a1135de5d9911838f4c020d73be9c462cba709d1 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 26 May 2011 15:46:15 +0200 Subject: fix blazar nil error --- lib/model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/model.rb b/lib/model.rb index 14471cc..edaa696 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -207,7 +207,7 @@ module OpenTox # AM: Balanced predictions addon = (modulo[1].to_f/modulo[0]).ceil # what will be added in each round - slack = modulo[1].divmod(addon)[1] # what remains for the last round + slack = (addon!=0 ? modulo[1].divmod(addon)[1] : 0) # what remains for the last round position = 0 predictions = Array.new -- cgit v1.2.3