public class CRFBiasedClassifier<IN extends CoreMap> extends CRFClassifier<IN>
CRFClassifier and supports most command-line parameters
available in CRFClassifier. In addition to this,
CRFBiasedClassifier also interprets the parameter -classBias, as in:
java -server -mx500m edu.stanford.nlp.ie.crf.CRFBiasedClassifier -loadClassifier model.gz -testFile test.txt -classBias A:0.5,B:1.5
The command above sets a bias of 0.5 towards class A and a bias of 1.5 towards class B. These biases (which internally are treated as feature weights in the log-linear model underpinning the CRF classifier) can take any real value. As the weight of A tends to plus infinity, the classifier will only predict A labels, and as it tends towards minus infinity, it will never predict A labels.
DEFAULT_CLASSIFIERclassIndex, featureFactories, flags, knownLCWords, pad, windowSize| Constructor and Description |
|---|
CRFBiasedClassifier(Properties props) |
CRFBiasedClassifier(SeqClassifierFlags flags) |
| Modifier and Type | Method and Description |
|---|---|
void |
adjustBias(List<List<IN>> develData,
java.util.function.Function<Double,Double> evalFunction,
double low,
double high)
Adjust the bias parameter to optimize some objective function.
|
List<IN> |
classify(List<IN> document)
|
static void |
main(String[] args)
The main method, which is essentially the same as in CRFClassifier.
|
CRFDatum<List<String>,CRFLabel> |
makeDatum(List<IN> info,
int loc,
List<FeatureFactory<IN>> featureFactories)
Makes a CRFDatum by producing features and a label from input data at a
specific position, using the provided factory.
|
void |
setBiasWeight(int cindex,
double weight) |
void |
setBiasWeight(String cname,
double weight) |
addProcessedData, allLabels, classifyGibbs, classifyGibbs, classifyMaxEnt, classifyWithGlobalInformation, combine, documentsToDataAndLabels, documentsToDataAndLabelsList, documentToDataAndLabels, dropFeaturesBelowThreshold, dumpFeatures, extractDatumSequence, getClassifier, getClassifier, getClassifier, getClassifier, getClassifierNoExceptions, getCliquePotentialFunctionForTest, getCliqueTree, getCliqueTree, getCliqueTrees, getDefaultClassifier, getDefaultClassifier, getJarClassifier, getMinimizer, getMinimizer, getNumWeights, getObjectiveFunction, getSequenceModel, loadAuxiliaryData, loadClassifier, loadClassIndexFromFile, loadDefaultClassifier, loadDefaultClassifier, loadFeatureIndexFromFile, loadProcessedData, loadTagIndex, loadTextClassifier, loadTextClassifier, loadWeightsFromFile, makeAnswerArraysAndTagIndex, printFactorTable, printFactorTableDocument, printFactorTableDocuments, printFeatures, printFirstOrderProbs, printFirstOrderProbsDocument, printFirstOrderProbsDocuments, printLabelInformation, printLabelValue, printProbsDocument, pruneNodeFeatureIndices, saveProcessedData, scaleWeights, serializeClassifier, serializeClassifier, serializeClassIndex, serializeFeatureIndex, serializeTextClassifier, serializeTextClassifier, serializeWeights, to2D, topWeights, train, trainWeights, updateWeightsForTest, writeWeightsapply, backgroundSymbol, classify, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswersKBest, classifyAndWriteAnswersKBest, classifyAndWriteViterbiSearchGraph, classifyFile, classifyFilesAndWriteAnswers, classifyFilesAndWriteAnswers, classifyKBest, classifyRaw, classifySentence, classifySentenceWithGlobalInformation, classifyStdin, classifyStdin, classifyToCharacterOffsets, classifyToString, classifyToString, classifyWithInlineXML, countResults, countResultsSegmenter, defaultReaderAndWriter, finalizeClassification, getKnownLCWords, getSampler, getViterbiSearchGraph, labels, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadJarClassifier, makeObjectBankFromFile, makeObjectBankFromFile, makeObjectBankFromFiles, makeObjectBankFromFiles, makeObjectBankFromFiles, makeObjectBankFromReader, makeObjectBankFromString, makePlainTextReaderAndWriter, makeReaderAndWriter, plainTextReaderAndWriter, printFeatureLists, printFeatures, printProbs, printProbsDocuments, printResults, reinit, segmentString, segmentString, train, train, train, train, train, train, windowSize, writeAnswersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitandThen, compose, identitypublic CRFBiasedClassifier(Properties props)
public CRFBiasedClassifier(SeqClassifierFlags flags)
public CRFDatum<List<String>,CRFLabel> makeDatum(List<IN> info, int loc, List<FeatureFactory<IN>> featureFactories)
CRFClassifiermakeDatum in class CRFClassifier<IN extends CoreMap>info - The input dataloc - The position to build a datum atfeatureFactories - The FeatureFactories to use to extract featurespublic void setBiasWeight(String cname, double weight)
public void setBiasWeight(int cindex,
double weight)
public List<IN> classify(List<IN> document)
AbstractSequenceClassifierList of something that extendsCoreMap.
The classifications are added in place to the items of the document,
which is also returned by this methodclassify in class CRFClassifier<IN extends CoreMap>document - A List of something that extends CoreMap.List, but with the elements annotated with their
answers (stored under the
CoreAnnotations.AnswerAnnotation
key).public void adjustBias(List<List<IN>> develData, java.util.function.Function<Double,Double> evalFunction, double low, double high)