Module: Rumale::Base::Classifier
- Included in:
- Ensemble::AdaBoostClassifier, Ensemble::GradientBoostingClassifier, Ensemble::RandomForestClassifier, KernelMachine::KernelSVC, LinearModel::LogisticRegression, LinearModel::SVC, Multiclass::OneVsRestClassifier, NaiveBayes::BaseNaiveBayes, NearestNeighbors::KNeighborsClassifier, PolynomialModel::FactorizationMachineClassifier, Tree::DecisionTreeClassifier
- Defined in:
- lib/rumale/base/classifier.rb
Overview
Module for all classifiers in Rumale.
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
Calculate the mean accuracy of the given testing data.
Instance Method Details
#fit ⇒ Object
An abstract method for fitting a model.
13 14 15 |
# File 'lib/rumale/base/classifier.rb', line 13 def fit raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#predict ⇒ Object
An abstract method for predicting labels.
18 19 20 |
# File 'lib/rumale/base/classifier.rb', line 18 def predict raise NotImplementedError, "#{__method__} has to be implemented in #{self.class}." end |
#score(x, y) ⇒ Float
Calculate the mean accuracy of the given testing data.
27 28 29 30 31 32 33 |
# File 'lib/rumale/base/classifier.rb', line 27 def score(x, y) check_sample_array(x) check_label_array(y) check_sample_label_size(x, y) evaluator = Rumale::EvaluationMeasure::Accuracy.new evaluator.score(y, predict(x)) end |