Class: Rumale::EvaluationMeasure::MedianAbsoluteError
- Inherits:
-
Object
- Object
- Rumale::EvaluationMeasure::MedianAbsoluteError
- Includes:
- Base::Evaluator
- Defined in:
- lib/rumale/evaluation_measure/median_absolute_error.rb
Overview
MedianAbsoluteError is a class that calculates the median absolute error.
Instance Method Summary collapse
-
#score(y_true, y_pred) ⇒ Float
Calculate median absolute error.
Instance Method Details
#score(y_true, y_pred) ⇒ Float
Calculate median absolute error.
20 21 22 23 24 25 26 27 |
# File 'lib/rumale/evaluation_measure/median_absolute_error.rb', line 20 def score(y_true, y_pred) check_tvalue_array(y_true) check_tvalue_array(y_pred) raise ArgumentError, 'Expect to have the same size both y_true and y_pred.' unless y_true.shape == y_pred.shape raise ArgumentError, 'Expect target values to be 1-D arrray' if [y_true.shape.size, y_pred.shape.size].max > 1 (y_true - y_pred).abs.median end |