Class: Clusterer::WeightNormalizedComplementBayes
- Inherits:
-
ComplementBayes
- Object
- Bayes
- ComplementBayes
- Clusterer::WeightNormalizedComplementBayes
- Includes:
- WeightNormalized
- Defined in:
- lib/clusterer/bayes.rb
Overview
Based on the description given in “Tackling the Poor Assumptions of Naive Bayes Text Classifiers” by Jason D. M. Rennie, Lawrence Shih, Jaime Teevan and David R. Karger, ICML - 2003
An improved complement bayes, the authors claim that this algorithm performs better, then the ComplementBayes. 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 ComplementBayes
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
234 235 236 237 238 239 240 |
# File 'lib/clusterer/bayes.rb', line 234 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 |