Class: OpenTox::Algorithm::Similarity
- Inherits:
-
Object
- Object
- OpenTox::Algorithm::Similarity
- Defined in:
- lib/algorithm.rb
Class Method Summary collapse
Class Method Details
.weighted_tanimoto(fp_a, fp_b, p) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/algorithm.rb', line 54 def self.weighted_tanimoto(fp_a,fp_b,p) common_features = fp_a & fp_b all_features = (fp_a + fp_b).uniq common_p_sum = 0.0 if common_features.size > 0 common_features.each{|f| common_p_sum += OpenTox::Utils.gauss(p[f])} all_p_sum = 0.0 all_features.each{|f| all_p_sum += OpenTox::Utils.gauss(p[f])} common_p_sum/all_p_sum else 0.0 end end |