Sha256: e18054c3dd25441df082d7ed3b9335760f8b394e155c07717861f3954281774f
Contents?: true
Size: 975 Bytes
Versions: 1
Compression:
Stored size: 975 Bytes
Contents
# frozen_string_literal: true module SVMKit module Base # Module for all classifiers in SVMKit. module Classifier # 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 # Claculate the mean accuracy of the given testing data. # # @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data. # @param y [Numo::Int32] (shape: [n_samples]) True labels for testing data. # @return [Float] Mean accuracy def score(x, y) SVMKit::Validation.check_sample_array(x) SVMKit::Validation.check_label_array(y) evaluator = SVMKit::EvaluationMeasure::Accuracy.new evaluator.score(y, predict(x)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
svmkit-0.2.8 | lib/svmkit/base/classifier.rb |