Class: Clusterer::WeightNormalizedMultinomialBayes
- Inherits:
-
MultinomialBayes
- Object
- Bayes
- MultinomialBayes
- Clusterer::WeightNormalizedMultinomialBayes
- Includes:
- WeightNormalized
- Defined in:
- lib/clusterer/bayes.rb
Overview
Hopefully an improved MultinomialBayes, based on the same ideas as the WeightNormalizedComplementBayes only using MultinomialBayes as the base. The weights are normalized, before using this algorithm.
Instance Attribute Summary
Attributes inherited from Bayes
Instance Method Summary collapse
Methods included from WeightNormalized
Methods inherited from MultinomialBayes
Methods inherited from Bayes
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Clusterer::Bayes
Instance Method Details
#distribution(document) ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/clusterer/bayes.rb', line 247 def distribution(document) self.class.superclass.superclass.instance_method(:distribution).bind(self).call do |cl,ind| we, sum = weighted_likelihood(cl), 0.0 document.each {|term,freq| sum += freq * (we[term] || 0)} sum end end |