diff options
author | dv <dv@dv.de> | 2011-07-20 11:03:24 +0200 |
---|---|---|
committer | dv <dv@dv.de> | 2011-07-20 11:03:24 +0200 |
commit | f938a796945c3b5f9bd29c6878facfc30aa1f926 (patch) | |
tree | 9d9cf21afa1ac51d793caf832239d56feaad3ffa | |
parent | de4d04a7f30e1c1743c14b81ee977fe5e750c5c8 (diff) |
modified arguments in add_neighbor,removed comments
-rw-r--r-- | lib/algorithm.rb | 22 | ||||
-rw-r--r-- | lib/model.rb | 9 |
2 files changed, 10 insertions, 21 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 352538b..5f3c328 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -169,25 +169,11 @@ module OpenTox params[:mode] = "max" params[:features] = all_features all_p_sum = Algorithm.p_sum_support(params) - #common_p_sum = 0.0 - #common_features.each{|f| - # compound_hits = params[:compound_features_hits][f] - # neighbor_hits = Algorithm.support(f,params) - # common_p = weights[f] * [compound_hits, neighbor_hits].min - # common_p_sum += Algorithm.gauss(common_p) - #} -# all_p_sum = 0.0 - #all_features.each{|f| - # compound_hits = params[:compound_features_hits][f] - # neighbor_hits = Algorithm.support(f,params) - # all_p = weights[f] * [compound_hits, neighbor_hits].max - # all_p_sum += Algorithm.gauss(all_p) - #} else common_p_sum = 0.0 - common_features.each{|f| common_p_sum += Algorithm.gauss(weights[f])}#*Algorithm.support(f,params))} + common_features.each{|f| common_p_sum += Algorithm.gauss(weights[f])} all_p_sum = 0.0 - all_features.each{|f| all_p_sum += Algorithm.gauss(weights[f])}#*Algorithm.support(f,params))} + all_features.each{|f| all_p_sum += Algorithm.gauss(weights[f])} end common_p_sum/all_p_sum else @@ -879,13 +865,9 @@ module OpenTox def self.p_sum_support(params) p_sum = 0.0 params[:features].each{|f| - #LOGGER.debug "compound_features_hits: #{params[:compound_features_hits][f]}" compound_hits = params[:compound_features_hits][f] - #LOGGER.debug "compound_hits: #{compound_hits}" neighbor_hits = Algorithm.support(f,params) - #LOGGER.debug "neighbor_hits: #{neighbor_hits}" p_sum += eval "(Algorithm.gauss(params[:weights][f]) * ([compound_hits, neighbor_hits].compact.#{params[:mode]}))" - #LOGGER.debug "p_sum: #{p_sum}" } p_sum end diff --git a/lib/model.rb b/lib/model.rb index f9f2685..4cbe95a 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -315,7 +315,14 @@ module OpenTox compound_features_hits = @compound.match_hits(@compound_features) #OpenTox::Compound.new(training_compound).match_hits(@compound_features) LOGGER.debug "dv ------------ compound_features_hits: #{@compound_features_hits}" end - sim = eval("#{@similarity_algorithm}(training_features, @compound_features, @p_values, ( { :training_compound => training_compound, :compound => @compound.uri, :fingerprints => @fingerprints, :nr_hits => @nr_hits, :compound_features_hits => compound_features_hits } ) )") + params = {} + params[:training_compound] = training_compound + params[:compound] = @compound.uri #query compound + params[:fingerprints] = @fingerprints + params[:nr_hits] = nr_hits + params[:compound_features_hits] = compound_features_hits + + sim = eval("#{@similarity_algorithm}(training_features, @compound_features, @p_values, params )") if sim > @min_sim @activities[training_compound].each do |act| @neighbors << { |