Module: Selector::IG
- Included in:
- BNS_IG, InformationGain
- Defined in:
- lib/svm_helper/selectors/calc.rb
Instance Method Summary collapse
Instance Method Details
#e(x, y) ⇒ Object
10 11 12 |
# File 'lib/svm_helper/selectors/calc.rb', line 10 def e(x,y) -xlx(x.quo(x+y)) -xlx(y.quo(x+y)) end |
#information_gain(pos, neg, tp, fp) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/svm_helper/selectors/calc.rb', line 3 def information_gain(pos, neg, tp, fp) fn = neg - fp tn = pos - tp p_word = (tp + fp).quo(pos + neg) e(pos, neg) - (p_word * e(tp, fp) + (1 - p_word) * e(fn, tn)) end |
#xlx(x) ⇒ Object
13 14 15 |
# File 'lib/svm_helper/selectors/calc.rb', line 13 def xlx(x) x * Math.log2(x) end |