diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-05-26 21:10:10 +0000 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-05-26 21:10:10 +0000 |
commit | 736b01c045331bb3787bf491bc4c11c222aea206 (patch) | |
tree | 594f07e639fc1ae8bfd587bc7c1d26dd562e40b7 /lib/model.rb | |
parent | 1ddea6e712319b7f21a6acf24739a2ef54c41042 (diff) | |
parent | a1135de5d9911838f4c020d73be9c462cba709d1 (diff) |
Merge branch 'development' of github.com:opentox/opentox-ruby into development
Diffstat (limited to 'lib/model.rb')
-rw-r--r-- | lib/model.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/model.rb b/lib/model.rb index 31a513e..baf01a6 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -175,11 +175,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 @@ -202,7 +206,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 @@ -230,6 +234,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 |