Module: LearnKit::NaiveBayes::Gaussian::Score
- Included in:
- LearnKit::NaiveBayes::Gaussian
- Defined in:
- lib/learn_kit/naive_bayes/gaussian/score.rb
Overview
Calc accuracy for test data
Instance Method Summary collapse
-
#score(total = 0, correct = 0) ⇒ Object
calculate accuracy for test data.
Instance Method Details
#score(total = 0, correct = 0) ⇒ Object
calculate accuracy for test data
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/learn_kit/naive_bayes/gaussian/score.rb', line 7 def score(total = 0, correct = 0) labels.each do |label_name| data_set[label_name].each do |feature| predicted_label = predict(feature) correct += 1 if predicted_label == label_name total += 1 end end total.zero? ? 0 : (correct * 100.0 / total).round(4) end |