Sha256: 4636e663bfcd3cf148283246ae122dff5c8924d4c7ffee8dfdeb6af953391a99
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
class Validator::Probability attr_accessor :prob_method def initialize(prob_method=:probability) @prob_method = prob_method end # objs should respond_to probability def precision(objs) return 1.0 if objs.size == 0 current_sum_one_minus_prob = 0.0 # this should work! #objs.inject(0.0) {|sum,obj| sum + (1.0 - obj.probability) } objs.each do |obj| # SUM(1-probX)/#objs current_sum_one_minus_prob += 1.0 - obj.send(@prob_method) end prec = 1.0 - (current_sum_one_minus_prob / objs.size) end # objs should respond_to probability # These should be added from high probability(1.0) to low (0.0) def increment_precision(objs) if objs.is_a?(SpecID::Pep) or objs.is_a?(SpecID::Prot) objs = [objs] end @total_objs ||= 0 @current_sum_one_minus_prob ||= 0.0 @total_objs += objs.size objs.each do |obj| @current_sum_one_minus_prob += 1.0 - obj.send(@prob_method) end prec = 1.0 - (@current_sum_one_minus_prob / @total_objs) end alias_method :pephit_precision, :precision alias_method :prothit_precision, :precision alias_method :increment_pephits_precision, :increment_precision end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mspire-0.3.0 | lib/validator/probability.rb |
mspire-0.3.1 | lib/validator/probability.rb |
mspire-0.3.9 | lib/validator/probability.rb |
mspire-0.4.2 | lib/validator/probability.rb |