Sha256: cb41e3ea4542e8a6b56d58c24ca76af73ab7eaf159e0f0b0d31c04166fa5e051

Contents?: true

Size: 835 Bytes

Versions: 8

Compression:

Stored size: 835 Bytes

Contents

# frozen_string_literal: true

require 'rumale/base/evaluator'

module Rumale
  module EvaluationMeasure
    # MeanSquaredError is a class that calculates the mean squared error.
    #
    # @example
    #   require 'rumale/evaluation_measure/mean_squared_error'
    #
    #   evaluator = Rumale::EvaluationMeasure::MeanSquaredError.new
    #   puts evaluator.score(ground_truth, predicted)
    class MeanSquaredError
      include ::Rumale::Base::Evaluator

      # Calculate mean squared error.
      #
      # @param y_true [Numo::DFloat] (shape: [n_samples, n_outputs]) Ground truth target values.
      # @param y_pred [Numo::DFloat] (shape: [n_samples, n_outputs]) Estimated target values.
      # @return [Float] Mean squared error
      def score(y_true, y_pred)
        ((y_true - y_pred)**2).mean
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rumale-evaluation_measure-1.0.0 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.29.0 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.28.1 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.28.0 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.27.0 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.26.0 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.25.0 lib/rumale/evaluation_measure/mean_squared_error.rb
rumale-evaluation_measure-0.24.0 lib/rumale/evaluation_measure/mean_squared_error.rb