Class: CrossLanguageSpotter::FiguresEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/crosslanguagespotter/figures_evaluator.rb

Overview

Calculates precision, recall, f-measure

Instance Method Summary collapse

Constructor Details

#initialize(gold_set, observed_set) ⇒ FiguresEvaluator

Gold set is the “truth”, observed is calculated from some method and compared with the gold set



122
123
124
125
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 122

def initialize(gold_set,observed_set)
    @gold_set     = gold_set
    @observed_set = observed_set
end

Instance Method Details

#all_figures(beta = 1.0) ⇒ Object



142
143
144
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 142

def all_figures(beta=1.0)
    {precision:precision,recall:recall,f_measure:f_measure(beta),beta:beta}
end

#f_measure(beta = 1.0) ⇒ Object



137
138
139
140
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 137

def f_measure(beta=1.0)
    beta_square = beta**2.0
    (2*(beta_square)*precision*recall)/(beta_square*precision+recall)
end

#precisionObject



127
128
129
130
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 127

def precision
    @precision = calc_precision unless @precision
    @precision
end

#recallObject



132
133
134
135
# File 'lib/crosslanguagespotter/figures_evaluator.rb', line 132

def recall
    @recall = calc_recall unless @recall
    @recall
end