Interface Classifier

All Known Subinterfaces:
IterativeClassifier
All Known Implementing Classes:
AbstractClassifier, AdaBoostM1, AdditiveRegression, AttributeSelectedClassifier, Bagging, BayesNet, BayesNetGenerator, BIFReader, ClassificationViaRegression, CostSensitiveClassifier, CVParameterSelection, DecisionStump, DecisionTable, EditableBayesNet, FilteredClassifier, GaussianProcesses, GeneralRegression, HoeffdingTree, IBk, InputMappedClassifier, IteratedSingleClassifierEnhancer, IterativeClassifierOptimizer, J48, JRip, KStar, LinearRegression, LMT, LMTNode, Logistic, LogisticBase, LogitBoost, LWL, M5Base, M5P, M5Rules, MultiClassClassifier, MultiClassClassifierUpdateable, MultilayerPerceptron, MultipleClassifiersCombiner, MultiScheme, NaiveBayes, NaiveBayesMultinomial, NaiveBayesMultinomialText, NaiveBayesMultinomialUpdateable, NaiveBayesUpdateable, NeuralNetwork, OneR, ParallelIteratedSingleClassifierEnhancer, ParallelMultipleClassifiersCombiner, PART, PMMLClassifier, PreConstructedLinearModel, RandomCommittee, RandomForest, RandomizableClassifier, RandomizableFilteredClassifier, RandomizableIteratedSingleClassifierEnhancer, RandomizableMultipleClassifiersCombiner, RandomizableParallelIteratedSingleClassifierEnhancer, RandomizableParallelMultipleClassifiersCombiner, RandomizableSingleClassifierEnhancer, RandomSubSpace, RandomTree, Regression, RegressionByDiscretization, REPTree, RuleNode, RuleSetModel, SerializedClassifier, SGD, SGDText, SimpleLinearRegression, SimpleLogistic, SingleClassifierEnhancer, SMO, SMOreg, Stacking, SupportVectorMachineModel, TreeModel, Vote, VotedPerceptron, WeightedInstancesHandlerWrapper, ZeroR

public interface Classifier
Classifier interface. All schemes for numeric or nominal prediction in Weka implement this interface. Note that a classifier MUST either implement distributionForInstance() or classifyInstance().
Version:
$Revision: 8034 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz), Len Trigg (trigg@cs.waikato.ac.nz)
  • Method Details

    • buildClassifier

      void buildClassifier(Instances data) throws Exception
      Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.
      Parameters:
      data - set of instances serving as training data
      Throws:
      Exception - if the classifier has not been generated successfully
    • classifyInstance

      double classifyInstance(Instance instance) throws Exception
      Classifies the given test instance. The instance has to belong to a dataset when it's being classified. Note that a classifier MUST implement either this or distributionForInstance().
      Parameters:
      instance - the instance to be classified
      Returns:
      the predicted most likely class for the instance or Utils.missingValue() if no prediction is made
      Throws:
      Exception - if an error occurred during the prediction
    • distributionForInstance

      double[] distributionForInstance(Instance instance) throws Exception
      Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value. Note that a classifier MUST implement either this or classifyInstance().
      Parameters:
      instance - the instance to be classified
      Returns:
      an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
      Throws:
      Exception - if distribution could not be computed successfully
    • getCapabilities

      Capabilities getCapabilities()
      Returns the Capabilities of this classifier. Maximally permissive capabilities are allowed by default. Derived classifiers should override this method and first disable all capabilities and then enable just those capabilities that make sense for the scheme.
      Returns:
      the capabilities of this object
      See Also: