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(java.util.Properties props) |
CRFBiasedClassifier(SeqClassifierFlags flags) |
| Modifier and Type | Method and Description |
|---|---|
void |
adjustBias(java.util.List<java.util.List<IN>> develData,
java.util.function.Function<java.lang.Double,java.lang.Double> evalFunction,
double low,
double high)
Adjust the bias parameter to optimize some objective function.
|
java.util.List<IN> |
classify(java.util.List<IN> document)
Classify a
List of something that extendsCoreMap. |
static void |
main(java.lang.String[] args)
The main method, which is essentially the same as in CRFClassifier.
|
CRFDatum<java.util.List<java.lang.String>,CRFLabel> |
makeDatum(java.util.List<IN> info,
int loc,
java.util.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(java.lang.String cname,
double weight) |
addProcessedData, allLabels, classifyGibbs, classifyGibbs, classifyMaxEnt, classifyWithGlobalInformation, combine, documentsToDataAndLabels, documentsToDataAndLabelsList, documentToDataAndLabels, dropFeaturesBelowThreshold, dumpFeatures, extractDatumSequence, getClassifier, 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, outputCalibrationInfo, plainTextReaderAndWriter, printFeatureLists, printFeatures, printProbs, printProbs, printProbsDocuments, printResults, reinit, segmentString, segmentString, train, train, train, train, train, train, windowSize, writeAnswerspublic CRFBiasedClassifier(java.util.Properties props)
public CRFBiasedClassifier(SeqClassifierFlags flags)
public CRFDatum<java.util.List<java.lang.String>,CRFLabel> makeDatum(java.util.List<IN> info, int loc, java.util.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(java.lang.String cname,
double weight)
public void setBiasWeight(int cindex,
double weight)
public java.util.List<IN> classify(java.util.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(java.util.List<java.util.List<IN>> develData, java.util.function.Function<java.lang.Double,java.lang.Double> evalFunction, double low, double high)
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception