ir.classifiers
Class Perceptron

java.lang.Object
  extended by ir.classifiers.Classifier
      extended by ir.classifiers.Perceptron

public class Perceptron
extends Classifier

A perceptron classifier that trains a perceptron to recognize each category.


Field Summary
protected  boolean debug
          Flag for debug print statements
static java.lang.String name
          Name of classifier
protected  int numCategories
          Number of categories
 
Fields inherited from class ir.classifiers.Classifier
categories, random
 
Constructor Summary
Perceptron(java.lang.String[] categories, boolean debug)
          Create an Perceptron classifier with these attributes
 
Method Summary
 java.lang.String getName()
          Returns the name
 void setDebug(boolean bool)
          Sets the debug flag
 void setInvertedIndex(InvertedIndex index)
          Since Perceptron does not use an inverted Index, this function does nothing
 boolean test(Example testExample)
          Categorizes the test example using the trained Perceptron classifier, returning true if the predicted category is same as the actual category
 void train(java.util.List trainExamples)
          Trains the perceptron by training a PerceptronUnit for each category.
 boolean usesInvertedIndex()
          Function to indicate that this class does not use an inverted index
 
Methods inherited from class ir.classifiers.Classifier
argMax, getCategories
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public static final java.lang.String name
Name of classifier

See Also:
Constant Field Values

numCategories

protected int numCategories
Number of categories


debug

protected boolean debug
Flag for debug print statements

Constructor Detail

Perceptron

public Perceptron(java.lang.String[] categories,
                  boolean debug)
Create an Perceptron classifier with these attributes

Parameters:
categories - The array of Strings containing the category names
debug - Flag to turn on detailed output
Method Detail

usesInvertedIndex

public boolean usesInvertedIndex()
Function to indicate that this class does not use an inverted index


setInvertedIndex

public void setInvertedIndex(InvertedIndex index)
Since Perceptron does not use an inverted Index, this function does nothing


setDebug

public void setDebug(boolean bool)
Sets the debug flag


getName

public java.lang.String getName()
Returns the name

Specified by:
getName in class Classifier
Returns:
the name of a particular classifier

train

public void train(java.util.List trainExamples)
Trains the perceptron by training a PerceptronUnit for each category.

Specified by:
train in class Classifier
Parameters:
trainExamples - The list of training examples

test

public boolean test(Example testExample)
Categorizes the test example using the trained Perceptron classifier, returning true if the predicted category is same as the actual category

Specified by:
test in class Classifier
Parameters:
testExample - The test example to be categorized