Class: Basset::NaiveBayes::FeatureCount
- Inherits:
-
Object
- Object
- Basset::NaiveBayes::FeatureCount
- Defined in:
- lib/basset/naive_bayes.rb
Overview
A class to store feature counts
Instance Method Summary collapse
- #add_count_for_class(count, classification) ⇒ Object
- #count ⇒ Object
- #count_for_class(classification) ⇒ Object
-
#initialize ⇒ FeatureCount
constructor
A new instance of FeatureCount.
Constructor Details
#initialize ⇒ FeatureCount
Returns a new instance of FeatureCount.
89 90 91 |
# File 'lib/basset/naive_bayes.rb', line 89 def initialize @classes = {} end |
Instance Method Details
#add_count_for_class(count, classification) ⇒ Object
93 94 95 96 |
# File 'lib/basset/naive_bayes.rb', line 93 def add_count_for_class(count, classification) @classes[classification] ||= 0 @classes[classification] += count end |
#count ⇒ Object
102 103 104 |
# File 'lib/basset/naive_bayes.rb', line 102 def count @classes.values.sum end |
#count_for_class(classification) ⇒ Object
98 99 100 |
# File 'lib/basset/naive_bayes.rb', line 98 def count_for_class(classification) @classes[classification] || 1 end |