summaryrefslogtreecommitdiff
path: root/lib/model.rb
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-05-25 10:24:13 +0200
committerAndreas Maunz <andreas@maunz.de>2011-05-25 10:24:13 +0200
commitbaffedfc7543cfc8a90fc185fc91f2748ce94528 (patch)
tree6fdfc40c8bd4b1f6f72eed977af29dde320bb43c /lib/model.rb
parentb7a03a18ce90d664d89d6a414512aa03a6dddcc4 (diff)
Fixed add_neighbor
Diffstat (limited to 'lib/model.rb')
-rw-r--r--lib/model.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/model.rb b/lib/model.rb
index f5e0410..3d27706 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -338,28 +338,45 @@ module OpenTox
@prediction_dataset
end
+ # Calculate the propositionalization matrix aka instantiation matrix (0/1 entries for features)
+# def get_prop_matrix
+# matrix = Array.new
+# begin
+# @neighbors.each do |n|
+# row = []
+# @features.each do |f|
+# row << @fingerprints[n].include?(f) ? 0.0 : @p_values[f]
+# end
+# matrix << row
+# end
+# rescue Exception => e
+# LOGGER.debug "get_prop_matrix failed with '" + $! + "'"
+# end
+# matrix
+# end
+
# Find neighbors and store them as object variable, access only a subset of compounds for that.
def neighbors_balanced(s, l, start, offset)
@compound_features = eval("#{@feature_calculation_algorithm}(@compound,@features)") if @feature_calculation_algorithm
@neighbors = []
[ l[start, offset ] , s ].flatten.each do |training_compound| # AM: access only a balanced subset
training_features = @fingerprints[training_compound]
- add_neighbor training_features
+ add_neighbor training_features, training_compound
end
end
- # Find neighbors and store them as object variable.
+ # Find neighbors and store them as object variable, access all compounds for that.
def neighbors
@compound_features = eval("#{@feature_calculation_algorithm}(@compound,@features)") if @feature_calculation_algorithm
@neighbors = []
@fingerprints.each do |training_compound,training_features| # AM: access all compounds
- add_neighbor training_features
+ add_neighbor training_features, training_compound
end
end
# Adds a neighbor to @neighbors if it passes the similarity threshold.
- def add_neighbor(training_features)
+ def add_neighbor(training_features, training_compound)
sim = eval("#{@similarity_algorithm}(@compound_features,training_features,@p_values)")
if sim > @min_sim
@activities[training_compound].each do |act|