weka.classifiers
Interface Classifier

All Known Implementing Classes:
AbstractClassifier, AdaBoostM1, AdditiveRegression, ADTree, AODE, AODEsr, AttributeSelectedClassifier, Bagging, BayesianLogisticRegression, BayesNet, BayesNetGenerator, BFTree, BIFReader, CitationKNN, ClassBalancedND, ClassificationViaClustering, ClassificationViaRegression, ComplementNaiveBayes, ConjunctiveRule, CostSensitiveClassifier, CVParameterSelection, Dagging, DataNearBalancedND, DecisionStump, DecisionTable, Decorate, DMNBtext, DTNB, EditableBayesNet, END, EnsembleSelection, FilteredClassifier, FLR, FT, FTInnerNode, FTLeavesNode, FTNode, FTtree, FURIA, GaussianProcesses, GeneralRegression, Grading, GridSearch, GroovyClassifier, HNB, HyperPipes, IB1, IBk, Id3, IsotonicRegression, IteratedSingleClassifierEnhancer, J48, J48graft, JRip, JythonClassifier, KStar, LADTree, LBR, LeastMedSq, LibLINEAR, LibSVM, LinearRegression, LMT, LMTNode, Logistic, LogisticBase, LogitBoost, LWL, M5Base, M5P, M5Rules, MDD, MetaCost, MIBoost, MIDD, MIEMDD, MILR, MINND, MIOptimalBall, MISMO, MISVM, MIWrapper, MultiBoostAB, MultiClassClassifier, MultilayerPerceptron, MultilayerPerceptronCS, MultipleClassifiersCombiner, MultiScheme, NaiveBayes, NaiveBayesMultinomial, NaiveBayesMultinomialUpdateable, NaiveBayesSimple, NaiveBayesUpdateable, NBTree, ND, NeuralNetwork, NNge, OLM, OneClassClassifier, OneR, OrdinalClassClassifier, OSDL, OSDLCore, PaceRegression, ParallelIteratedSingleClassifierEnhancer, ParallelMultipleClassifiersCombiner, PART, PLSClassifier, PMMLClassifier, PreConstructedLinearModel, Prism, RacedIncrementalLogitBoost, RandomCommittee, RandomForest, RandomizableClassifier, RandomizableIteratedSingleClassifierEnhancer, RandomizableMultipleClassifiersCombiner, RandomizableParallelIteratedSingleClassifierEnhancer, RandomizableParallelMultipleClassifiersCombiner, RandomizableSingleClassifierEnhancer, RandomSubSpace, RandomTree, RBFNetwork, RealAdaBoost, Regression, RegressionByDiscretization, REPTree, Ridor, RotationForest, RuleNode, RuleSetModel, SerializedClassifier, SimpleCart, SimpleLinearRegression, SimpleLogistic, SimpleMI, SingleClassifierEnhancer, SMO, SMOreg, SPegasos, Stacking, StackingC, ThresholdSelector, TLD, TLDSimple, TreeModel, UserClassifier, VFI, Vote, VotedPerceptron, WAODE, Winnow, 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: 6041 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz), Len Trigg (trigg@cs.waikato.ac.nz)

Method Summary
 void buildClassifier(Instances data)
          Generates a classifier.
 double classifyInstance(Instance instance)
          Classifies the given test instance.
 double[] distributionForInstance(Instance instance)
          Predicts the class memberships for a given instance.
 Capabilities getCapabilities()
          Returns the Capabilities of this classifier.
 

Method Detail

buildClassifier

void buildClassifier(Instances data)
                     throws java.lang.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:
java.lang.Exception - if the classifier has not been generated successfully

classifyInstance

double classifyInstance(Instance instance)
                        throws java.lang.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:
java.lang.Exception - if an error occurred during the prediction

distributionForInstance

double[] distributionForInstance(Instance instance)
                                 throws java.lang.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:
java.lang.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:
Capabilities