Module: Clusterer::WeightNormalized

Included in:
WeightNormalizedComplementBayes, WeightNormalizedMultinomialBayes
Defined in:
lib/clusterer/bayes.rb

Overview

Module to help in implementing weighted form of MultimonialBayes and ComplementBayes. For performance reasons the normalized classifier weights are cached. These weights are calculated only when the classifier is first used for training or prediction. Training or Untraining an instance clears the cached normalized weights.

Instance Method Summary collapse

Instance Method Details

#initialize(categories, options = { }) ⇒ Object



198
199
200
201
# File 'lib/clusterer/bayes.rb', line 198

def initialize(categories, options = { })
  super
  @weighted_likelihood = Hash.new
end

#train(document, category) ⇒ Object



203
204
205
206
# File 'lib/clusterer/bayes.rb', line 203

def train(document, category)
  super
  @weighted_likelihood.clear
end

#untrain(document, category) ⇒ Object



208
209
210
211
# File 'lib/clusterer/bayes.rb', line 208

def untrain(document, category)
  super
  @weighted_likelihood.clear
end