Module: ML::Learner::Toolbox
- Included in:
- CyclicDescentLearner, DecisionStumpLearner, LinearRegressionLearner, LogisticRegressionLearner, PerceptronLearner
- Defined in:
- lib/method/toolbox.rb
Overview
General toolbox for learning methods
Instance Method Summary collapse
-
#classify_error(supervised_data) ⇒ Object
Calculating model error.
-
#predict(data) ⇒ Integer
Predict a single data with current prediction.
Instance Method Details
#classify_error(supervised_data) ⇒ Object
Calculating model error
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
12 13 14 |
# File 'lib/method/toolbox.rb', line 12 def predict data raise "Cannot predict" end |