Class: Rumale::EvaluationMeasure::Precision
- Inherits:
-
Object
- Object
- Rumale::EvaluationMeasure::Precision
- Includes:
- Base::Evaluator
- Defined in:
- rumale-evaluation_measure/lib/rumale/evaluation_measure/precision.rb
Overview
Precision is a class that calculates the preicision of the predicted labels.
Instance Attribute Summary collapse
-
#average ⇒ String
readonly
Return the average type for calculation of precision.
Instance Method Summary collapse
-
#initialize(average: 'binary') ⇒ Precision
constructor
Create a new evaluation measure calculater for precision score.
-
#score(y_true, y_pred) ⇒ Float
Calculate average precision.
Constructor Details
#initialize(average: 'binary') ⇒ Precision
Create a new evaluation measure calculater for precision score.
27 28 29 |
# File 'rumale-evaluation_measure/lib/rumale/evaluation_measure/precision.rb', line 27 def initialize(average: 'binary') @average = average end |
Instance Attribute Details
#average ⇒ String (readonly)
Return the average type for calculation of precision.
22 23 24 |
# File 'rumale-evaluation_measure/lib/rumale/evaluation_measure/precision.rb', line 22 def average @average end |
Instance Method Details
#score(y_true, y_pred) ⇒ Float
Calculate average precision.
36 37 38 39 40 41 42 43 44 45 |
# File 'rumale-evaluation_measure/lib/rumale/evaluation_measure/precision.rb', line 36 def score(y_true, y_pred) case @average when 'binary' precision_each_class(y_true, y_pred).last when 'micro' micro_average_precision(y_true, y_pred) when 'macro' macro_average_precision(y_true, y_pred) end end |