Class: Rumale::EvaluationMeasure::FScore
- Inherits:
-
Object
- Object
- Rumale::EvaluationMeasure::FScore
- Includes:
- Base::Evaluator
- Defined in:
- lib/rumale/evaluation_measure/f_score.rb
Overview
FScore is a class that calculates the F1-score of the predicted labels.
Instance Attribute Summary collapse
-
#average ⇒ String
readonly
Return the average type for calculation of F1-score.
Instance Method Summary collapse
-
#initialize(average: 'binary') ⇒ FScore
constructor
Create a new evaluation measure calculater for F1-score.
-
#score(y_true, y_pred) ⇒ Float
Calculate average F1-score.
Constructor Details
#initialize(average: 'binary') ⇒ FScore
Create a new evaluation measure calculater for F1-score.
25 26 27 28 |
# File 'lib/rumale/evaluation_measure/f_score.rb', line 25 def initialize(average: 'binary') check_params_string(average: average) @average = average end |
Instance Attribute Details
#average ⇒ String (readonly)
Return the average type for calculation of F1-score.
20 21 22 |
# File 'lib/rumale/evaluation_measure/f_score.rb', line 20 def average @average end |
Instance Method Details
#score(y_true, y_pred) ⇒ Float
Calculate average F1-score
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rumale/evaluation_measure/f_score.rb', line 35 def score(y_true, y_pred) check_label_array(y_true) check_label_array(y_pred) case @average when 'binary' f_score_each_class(y_true, y_pred).last when 'micro' micro_average_f_score(y_true, y_pred) when 'macro' macro_average_f_score(y_true, y_pred) end end |