|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ir.classifiers.Classifier ir.classifiers.Perceptron
public class Perceptron
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 |
---|
public static final java.lang.String name
protected int numCategories
protected boolean debug
Constructor Detail |
---|
public Perceptron(java.lang.String[] categories, boolean debug)
categories
- The array of Strings containing the category namesdebug
- Flag to turn on detailed outputMethod Detail |
---|
public boolean usesInvertedIndex()
public void setInvertedIndex(InvertedIndex index)
public void setDebug(boolean bool)
public java.lang.String getName()
getName
in class Classifier
public void train(java.util.List trainExamples)
train
in class Classifier
trainExamples
- The list of training examplespublic boolean test(Example testExample)
test
in class Classifier
testExample
- The test example to be categorized
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |