Class: ML::Learner::CyclicDescentLearner
- Inherits:
-
Object
- Object
- ML::Learner::CyclicDescentLearner
- Includes:
- LinearToolbox, Toolbox
- Defined in:
- lib/method/cyclic_descent.rb
Overview
Implementation of cyclic coordinate descent learner
Instance Attribute Summary
Attributes included from LinearToolbox
Instance Method Summary collapse
-
#initialize(dim, model = :basis) ⇒ CyclicDescentLearner
constructor
Initialize a learner.
-
#train!(data, iteration = 1000) ⇒ Object
Train with a supervised data.
Methods included from LinearToolbox
Methods included from Toolbox
Constructor Details
#initialize(dim, model = :basis) ⇒ CyclicDescentLearner
Initialize a learner
13 14 15 16 |
# File 'lib/method/cyclic_descent.rb', line 13 def initialize dim, model = :basis @dim = dim @model = model end |
Instance Method Details
#train!(data, iteration = 1000) ⇒ Object
Train with a supervised data
22 23 24 25 26 27 28 29 |
# File 'lib/method/cyclic_descent.rb', line 22 def train! data, iteration = 1000 self.current_vector = Matrix.column_vector(Array.new(@dim + 1, 0)) iteration.times do |i| v = calc_v i eta = calc_eta data, v self.current_vector += eta * v end end |