Class: PaLearner::PA

Inherits:
Object
  • Object
show all
Includes:
PaLearner
Defined in:
lib/pa_learner.rb

Constant Summary

Constants included from PaLearner

EPS_TO_AVOID_ZERO_DIV, VERSION

Instance Attribute Summary

Attributes included from PaLearner

#w

Instance Method Summary collapse

Methods included from PaLearner

#bin_classify, #estimate

Constructor Details

#initialize(n, type = :pa, cost = 0) ⇒ PA

Returns a new instance of PA.



16
17
18
19
20
21
# File 'lib/pa_learner.rb', line 16

def initialize(n, type=:pa, cost = 0)
  pa_kickstart( n )
  @type = type
  @cost = cost
  self
end

Instance Method Details

#update!(x, y) ⇒ Object



23
24
25
26
27
28
# File 'lib/pa_learner.rb', line 23

def update!(x, y)
  l = hinge_loss( x, y )
  etta = calc_update_delta( l, x)
  @w.each_index { |i| @w[i] += y*etta*x[i] }
  self
end