Sha256: f769964d521364cce71640791b877084e84291569007b6cad70ee662634f40ea
Contents?: true
Size: 1.12 KB
Versions: 17
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require 'svmkit/validation' require 'svmkit/evaluation_measure/r2_score' module SVMKit module Base # Module for all regressors in SVMKit. module Regressor # 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) SVMKit::Validation.check_sample_array(x) SVMKit::Validation.check_tvalue_array(y) SVMKit::Validation.check_sample_tvalue_size(x, y) evaluator = SVMKit::EvaluationMeasure::R2Score.new evaluator.score(y, predict(x)) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems