summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/model.rb11
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