Class Classifier

java.lang.Object
  extended by Classifier
Direct Known Subclasses:
DecisionStump, DecisionTree, NaiveBayes, OneRClassifier

public abstract class Classifier
extends java.lang.Object

The Classifier class represents an algorithm for classifying the instances of a particular machine learning problem. Classifier is an abstract class, so actual classification algorithms are implemented by extending this class and implementing the abstract methods.

Author:
jmac

Field Summary
static java.lang.String missingData
           
static java.lang.String unknownClass
           
 
Constructor Summary
Classifier(AttributeSet attributeSet)
           
 
Method Summary
abstract  java.util.Hashtable<java.lang.String,java.lang.Double> computeClassProbabilities(Instance instance)
           
 double computeErrorRate(InstanceSet testSet)
           
abstract  java.lang.String decide(Instance instance)
           
 AttributeSet getAttributeSet()
           
abstract  void learn(InstanceSet trainingSet)
          Learn a classifier from the given training set
static void main(java.lang.String[] arguments)
          Run a user-selected algorithm on a user-selected data file
abstract  void print()
          print out a legible form of the classifier
 void printDecisionsAndProbabilities(InstanceSet testSet)
          Print out the decision (i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

missingData

public static final java.lang.String missingData
See Also:
Constant Field Values

unknownClass

public static final java.lang.String unknownClass
See Also:
Constant Field Values
Constructor Detail

Classifier

public Classifier(AttributeSet attributeSet)
Parameters:
attributeSet - the set of attributes to be used by this classifier
Method Detail

learn

public abstract void learn(InstanceSet trainingSet)
                    throws java.lang.Exception
Learn a classifier from the given training set

Parameters:
trainingSet - the training set from which to learn the classifier
Throws:
java.lang.Exception

decide

public abstract java.lang.String decide(Instance instance)
                                 throws java.lang.Exception
Parameters:
instance - the instance whose class is to be decided
Returns:
the class value of the instance
Throws:
java.lang.Exception

computeClassProbabilities

public abstract java.util.Hashtable<java.lang.String,java.lang.Double> computeClassProbabilities(Instance instance)
                                                                                          throws java.lang.Exception
Parameters:
instance - the instance whose class probabilities are to be computed
Returns:
a table mapping class values to their probabilities
Throws:
java.lang.Exception

print

public abstract void print()
                    throws java.lang.Exception
print out a legible form of the classifier

Throws:
java.lang.Exception

computeErrorRate

public double computeErrorRate(InstanceSet testSet)
                        throws java.lang.Exception
Parameters:
testSet - the test set on which the error rate will be computed
Returns:
the error rate, expressed as a number between 0 and 1, of this classifier on the given test set
Throws:
java.lang.Exception

printDecisionsAndProbabilities

public void printDecisionsAndProbabilities(InstanceSet testSet)
                                    throws java.lang.Exception
Print out the decision (i.e. which class does the classifier believe this instance belongs to) and class probabilities for each instance in the given test set

Parameters:
testSet - the test set whose decision and probabilities should be printed out
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] arguments)
Run a user-selected algorithm on a user-selected data file

Parameters:
arguments - OneR|Bayes|Stump|Tree datafilename

getAttributeSet

public AttributeSet getAttributeSet()
Returns:
the attributeSet used by this machine learning problem