Module: SVMKit::Base::Classifier
- Included in:
- Ensemble::RandomForestClassifier, KernelMachine::KernelSVC, LinearModel::LogisticRegression, LinearModel::SVC, Multiclass::OneVsRestClassifier, NaiveBayes::BaseNaiveBayes, NearestNeighbors::KNeighborsClassifier, PolynomialModel::FactorizationMachineClassifier, Tree::DecisionTreeClassifier
- Defined in:
- lib/svmkit/base/classifier.rb
Overview
Module for all classifiers in SVMKit.
Instance Method Summary collapse
-
#fit ⇒ Object
An abstract method for fitting a model.
-
#predict ⇒ Object
An abstract method for predicting labels.
-
#score(x, y) ⇒ Float
Claculate the mean accuracy of the given testing data.
Instance Method Details
#fit ⇒ Object
An abstract method for fitting a model.
8 9 10 |
# File 'lib/svmkit/base/classifier.rb', line 8 def fit raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#predict ⇒ Object
An abstract method for predicting labels.
13 14 15 |
# File 'lib/svmkit/base/classifier.rb', line 13 def predict raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#score(x, y) ⇒ Float
Claculate the mean accuracy of the given testing data.
22 23 24 25 |
# File 'lib/svmkit/base/classifier.rb', line 22 def score(x, y) evaluator = SVMKit::EvaluationMeasure::Accuracy.new evaluator.score(y, predict(x)) end |