Class: Rumale::EvaluationMeasure::MeanSquaredError

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

Overview

MeanSquaredError is a class that calculates the mean squared error.

Examples:

require 'rumale/evaluation_measure/mean_squared_error'

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

Instance Method Summary collapse

Instance Method Details

#score(y_true, y_pred) ⇒ Float

Calculate mean squared error.

Parameters:

  • y_true (Numo::DFloat)

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

  • y_pred (Numo::DFloat)

    (shape: [n_samples, n_outputs]) Estimated target values.

Returns:

  • (Float)

    Mean squared error



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

def score(y_true, y_pred)
  ((y_true - y_pred)**2).mean
end