Class: PaLearner::PA
Constant Summary
Constants included from PaLearner
EPS_TO_AVOID_ZERO_DIV, VERSION
Instance Attribute Summary
Attributes included from PaLearner
Instance Method Summary collapse
-
#initialize(n, type = :pa, cost = 0) ⇒ PA
constructor
A new instance of PA.
- #update!(x, y) ⇒ Object
Methods included from PaLearner
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 |