Module: SecEdgar::BasicStats

Extended by:
BasicStats
Included in:
BasicStats
Defined in:
lib/sec_edgar/basic_stats.rb

Instance Method Summary collapse

Instance Method Details

#f1(tp, fp, fn) ⇒ Object



20
21
22
23
24
# File 'lib/sec_edgar/basic_stats.rb', line 20

def f1(tp, fp, fn)
  p = precision(tp, fp)
  r = recall(tp, fn)
  2 * ((p * r).fdiv(p + r))
end

#f_beta(tp, fp, fn, beta) ⇒ Object



13
14
15
16
17
18
# File 'lib/sec_edgar/basic_stats.rb', line 13

def f_beta(tp, fp, fn, beta)
  p = precision(tp, fp)
  r = recall(tp, fn)
  b2 = beta ** 2
  (1 + b2) * ((p * r).fdiv((b2 * p) + r))
end

#precision(tp, fp) ⇒ Object



5
6
7
# File 'lib/sec_edgar/basic_stats.rb', line 5

def precision(tp, fp)
  tp.fdiv(tp + fp)
end

#recall(tp, fn) ⇒ Object



9
10
11
# File 'lib/sec_edgar/basic_stats.rb', line 9

def recall(tp, fn)
  tp.fdiv(tp + fn)
end