Class: Rumale::EvaluationMeasure::MedianAbsoluteError

Inherits:
Object
  • Object
show all
Includes:
Base::Evaluator
Defined in:
rumale-evaluation_measure/lib/rumale/evaluation_measure/median_absolute_error.rb

Overview

MedianAbsoluteError is a class that calculates the median absolute error.

Examples:

require 'rumale/evaluation_measure/median_absolute_error'

evaluator = Rumale::EvaluationMeasure::MedianAbsoluteError.new
puts evaluator.score(ground_truth, predicted)

Instance Method Summary collapse

Instance Method Details

#score(y_true, y_pred) ⇒ Float

Calculate median absolute error.

Parameters:

  • y_true (Numo::DFloat)

    (shape: [n_samples]) Ground truth target values.

  • y_pred (Numo::DFloat)

    (shape: [n_samples]) Estimated target values.

Returns:

  • (Float)

    Median absolute error.



22
23
24
# File 'rumale-evaluation_measure/lib/rumale/evaluation_measure/median_absolute_error.rb', line 22

def score(y_true, y_pred)
  (y_true - y_pred).abs.median
end