module ML::Learner::LinearToolbox
Learner
toolbox for linear model
The prediction is a vector of dimension d+1 where d is the dimension of the input data
Attributes
current_vector[RW]
Current prediction vector
Public Instance Methods
line()
click to toggle source
The final coefficient of the line
@return [Array] [a,b,c] for ax+by+c=0 for 2-d case
# File lib/method/toolbox.rb, line 51 def line current_vector.column(0).to_a end
predict(data)
click to toggle source
Predict certain data
@param [Array] data data in question @return [Integer] prediction
# File lib/method/toolbox.rb, line 44 def predict data classify_bool Matrix.column_vector(data) end
Protected Instance Methods
classify_bool(data)
click to toggle source
Classify with single data with 0/1 error
@param [Matrix] data input column vector @return [Integer] classified data
# File lib/method/toolbox.rb, line 60 def classify_bool data classify_inner(data) <=> 0 end
classify_inner(data)
click to toggle source
Classify with single data with inner product
@param [Matrix] data input column vector @return [Integer] classified data
# File lib/method/toolbox.rb, line 68 def classify_inner data (current_vector.transpose * data)[0,0] end