Class: Rumale::EvaluationMeasure::Accuracy
- Inherits:
-
Object
- Object
- Rumale::EvaluationMeasure::Accuracy
- Includes:
- Base::Evaluator
- Defined in:
- rumale-evaluation_measure/lib/rumale/evaluation_measure/accuracy.rb
Overview
Accuracy is a class that calculates the accuracy of classifier from the predicted labels.
Instance Method Summary collapse
-
#score(y_true, y_pred) ⇒ Float
Calculate mean accuracy.
Instance Method Details
#score(y_true, y_pred) ⇒ Float
Calculate mean accuracy.
22 23 24 |
# File 'rumale-evaluation_measure/lib/rumale/evaluation_measure/accuracy.rb', line 22 def score(y_true, y_pred) (y_true.to_a.map.with_index { |label, n| label == y_pred[n] ? 1 : 0 }).sum / y_true.size.to_f end |