Sha256: 1b8d3b4d482a7467d6bfd506084ec04ac767a9c6ea7c43c2447b9ea1b5c78ad6
Contents?: true
Size: 1.01 KB
Versions: 28
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'rumale/base/evaluator' module Rumale module EvaluationMeasure # MeanSquaredLogError is a class that calculates the mean squared logarithmic error. # # @example # evaluator = Rumale::EvaluationMeasure::MeanSquaredError.new # puts evaluator.score(ground_truth, predicted) class MeanSquaredLogError include Base::Evaluator # Calculate mean squared logarithmic 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 logarithmic error. 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 ((Numo::NMath.log(y_true + 1) - Numo::NMath.log(y_pred + 1))**2).mean end end end end
Version data entries
28 entries across 28 versions & 1 rubygems