Class: Quarry::ConfusionMatrix
- Inherits:
-
Object
- Object
- Quarry::ConfusionMatrix
- Defined in:
- lib/quarry_rb/confusion_matrix.rb
Instance Attribute Summary collapse
-
#confusion_matrix ⇒ Object
readonly
Returns the value of attribute confusion_matrix.
-
#data_set ⇒ Object
readonly
Returns the value of attribute data_set.
Instance Method Summary collapse
- #accuracy ⇒ Object
- #add(predicted, actual) ⇒ Object
- #error ⇒ Object
- #fn(category) ⇒ Object
- #fp(category) ⇒ Object
- #fscore(category) ⇒ Object
-
#initialize(data_set, matrix = nil) ⇒ ConfusionMatrix
constructor
A new instance of ConfusionMatrix.
- #precision(category) ⇒ Object
- #print_summary ⇒ Object
- #recall(category) ⇒ Object
- #tn(category) ⇒ Object
- #tp(category) ⇒ Object
Constructor Details
#initialize(data_set, matrix = nil) ⇒ ConfusionMatrix
Returns a new instance of ConfusionMatrix.
5 6 7 8 9 10 11 12 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 5 def initialize(data_set, matrix=nil) @data_set = data_set if matrix @confusion_matrix = matrix else @confusion_matrix = Quarry::ImplConfusionMatrix.new(data_set.data_set) end end |
Instance Attribute Details
#confusion_matrix ⇒ Object (readonly)
Returns the value of attribute confusion_matrix.
3 4 5 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 3 def confusion_matrix @confusion_matrix end |
#data_set ⇒ Object (readonly)
Returns the value of attribute data_set.
4 5 6 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 4 def data_set @data_set end |
Instance Method Details
#accuracy ⇒ Object
18 19 20 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 18 def accuracy @confusion_matrix.accuracy end |
#add(predicted, actual) ⇒ Object
14 15 16 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 14 def add(predicted, actual) @confusion_matrix.add(predicted.category, actual.category) end |
#error ⇒ Object
22 23 24 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 22 def error @confusion_matrix.error end |
#fn(category) ⇒ Object
38 39 40 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 38 def fn(category) @confusion_matrix.fn(category.category) end |
#fp(category) ⇒ Object
30 31 32 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 30 def fp(category) @confusion_matrix.fp(category.category) end |
#fscore(category) ⇒ Object
50 51 52 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 50 def fscore(category) @confusion_matrix.fscore(category) end |
#precision(category) ⇒ Object
42 43 44 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 42 def precision(category) @confusion_matrix.precision(category) end |
#print_summary ⇒ Object
54 55 56 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 54 def print_summary @confusion_matrix.print_summary end |
#recall(category) ⇒ Object
46 47 48 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 46 def recall(category) @confusion_matrix.recall(category) end |
#tn(category) ⇒ Object
34 35 36 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 34 def tn(category) @confusion_matrix.tn(category.category) end |
#tp(category) ⇒ Object
26 27 28 |
# File 'lib/quarry_rb/confusion_matrix.rb', line 26 def tp(category) @confusion_matrix.tp(category.category) end |