Class: Quarry::ConfusionMatrix

Inherits:
Object
  • Object
show all
Defined in:
lib/quarry_rb/confusion_matrix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_matrixObject (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_setObject (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

#accuracyObject



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

#errorObject



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


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