public class NBClassifier extends AbstractClassifier
Naive Bayesian classifier which uses Laplacian smoothing
Copyright: Copyright (c) 2005
Company: IST, Drexel University
| Modifier and Type | Field and Description |
|---|---|
protected DoubleVector |
classPrior |
protected DoubleVector |
lastClassProb |
protected DoubleFlatDenseMatrix |
model |
arrLabel, classNum, doctermMatrix, featureSelector, indexReader, validatingDocSet| Constructor and Description |
|---|
NBClassifier(IndexReader indexReader) |
NBClassifier(SparseMatrix doctermMatrix) |
NBClassifier(String modelFile) |
| Modifier and Type | Method and Description |
|---|---|
int |
classify(IRDoc doc)
Classify one particular document
|
int |
classify(Row doc)
Classify one particular document
|
protected DoubleVector |
getClassPrior(DocClassSet docSet) |
int[] |
rank()
Rank all class labels.
|
void |
saveModel(String modelFile)
Save the trained classifier model to a file which can be used to restore the classifier later.
|
void |
train(DocClassSet trainingDocSet)
This method trains the classifier with the training document set.
|
classify, classify, classify, getClassLabel, getDocTermMatrix, getFeatureSelector, getIndexReader, getRow, setFeatureSelector, train, trainFeatureSelectorprotected DoubleFlatDenseMatrix model
protected DoubleVector classPrior
protected DoubleVector lastClassProb
public NBClassifier(String modelFile)
public NBClassifier(IndexReader indexReader)
public NBClassifier(SparseMatrix doctermMatrix)
public void train(DocClassSet trainingDocSet)
ClassifiertrainingDocSet - training document setprotected DoubleVector getClassPrior(DocClassSet docSet)
public int classify(IRDoc doc)
Classifierclassify in interface Classifierclassify in class AbstractClassifierdoc - the index of the document is stored in the IRDoc objectpublic int classify(Row doc)
Classifierdoc - document represented by a Row objectpublic int[] rank()
Classifierpublic void saveModel(String modelFile)
ClassifiermodelFile - output file nameCopyright © 2018 JULIE Lab, Germany. All rights reserved.