Sha256: 29cfde375b30323a0b47144597bf0d29ff4b97d4d4f257e061c77ad62bc82e8a
Contents?: true
Size: 1.12 KB
Versions: 40
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require 'rumale/validation' require 'rumale/evaluation_measure/r2_score' module Rumale module Base # Module for all regressors in Rumale. module Regressor include Validation # An abstract method for fitting a model. def fit raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end # An abstract method for predicting labels. def predict raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end # Calculate the coefficient of determination for the given testing data. # # @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data. # @param y [Numo::DFloat] (shape: [n_samples, n_outputs]) Target values for testing data. # @return [Float] Coefficient of determination def score(x, y) x = check_convert_sample_array(x) y = check_convert_tvalue_array(y) check_sample_tvalue_size(x, y) evaluator = Rumale::EvaluationMeasure::R2Score.new evaluator.score(y, predict(x)) end end end end
Version data entries
40 entries across 40 versions & 1 rubygems