Class: PositronicBrain::Persistence::Classifier::Base
- Inherits:
-
Base
- Object
- Base
- PositronicBrain::Persistence::Classifier::Base
show all
- Defined in:
- lib/positronic_brain/persistence/classifier/base.rb
Instance Attribute Summary
Attributes inherited from Base
#dump_path, #options, #persistence
Instance Method Summary
collapse
Methods inherited from Base
#==, #dump, #initialize
Instance Method Details
#categories ⇒ Object
33
34
35
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 33
def categories
@persistence[:categories].keys
end
|
#category_count(category) ⇒ Object
9
10
11
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 9
def category_count(category)
(@persistence[:categories][category] || 0.0).to_f
end
|
#feature_count(feature) ⇒ Object
5
6
7
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 5
def feature_count(feature)
(@persistence[:features][feature] || 0.0).to_f
end
|
#feature_in_category_count(feature, category) ⇒ Object
13
14
15
16
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 13
def feature_in_category_count(feature, category)
return 0.0 unless @persistence[:features_in_category].has_key?(feature)
(@persistence[:features_in_category][feature][category] || 0.0).to_f
end
|
#increment_category(category) ⇒ Object
27
28
29
30
31
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 27
def increment_category(category)
@persistence[:categories][category] ||= 0
@persistence[:categories][category] += 1
@persistence[:total_count] += 1
end
|
#increment_feature(feature, category) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 18
def increment_feature(feature, category)
@persistence[:features_in_category][feature] ||= Hash.new
@persistence[:features_in_category][feature][category] ||= 0
@persistence[:features_in_category][feature][category] += 1
@persistence[:features][feature] ||= 0
@persistence[:features][feature] += 1
end
|
#total_count ⇒ Object
37
38
39
|
# File 'lib/positronic_brain/persistence/classifier/base.rb', line 37
def total_count
(@persistence[:total_count] || 0.0).to_f
end
|