Module: ML::Learner::Toolbox

Overview

General toolbox for learning methods

Instance Method Summary collapse

Instance Method Details

#classify_error(supervised_data) ⇒ Object

Calculating model error

Parameters:

  • data (Hash)

    supervised input data (mapping from array to integer)



20
21
22
23
24
25
26
27
28
29
# File 'lib/method/toolbox.rb', line 20

def classify_error supervised_data
  error = 0

  for data, result in supervised_data
    classified_result = predict(data)
    error += 1 unless result == classified_result
  end

  error.to_f / supervised_data.size
end

#predict(data) ⇒ Integer

Predict a single data with current prediction

Parameters:

  • data (Array)

    input vector array

Returns:

  • (Integer)

    classified data



12
13
14
# File 'lib/method/toolbox.rb', line 12

def predict data
  raise "Cannot predict"
end