public Pipe getPipe() { return model.getInstancePipe(); } }
public ConfidencePredictingClassifier (Classifier underlyingClassifier, Classifier confidencePredictingClassifier) { super (underlyingClassifier.getInstancePipe()); this.underlyingClassifier = underlyingClassifier; this.confidencePredictingClassifier = confidencePredictingClassifier; // for testing confidence accuracy totalCorrect = 0.0; totalIncorrect = 0.0; totalIncorrectIncorrect = 0.0; totalIncorrectCorrect = 0.0; numCorrectInstances = 0; numIncorrectInstances = 0; numConfidenceCorrect = 0; numFalsePositive = 0; numFalseNegative = 0; }
public ConfidencePredictingClassifier (Classifier underlyingClassifier, Classifier confidencePredictingClassifier) { super (underlyingClassifier.getInstancePipe()); this.underlyingClassifier = underlyingClassifier; this.confidencePredictingClassifier = confidencePredictingClassifier; // for testing confidence accuracy totalCorrect = 0.0; totalIncorrect = 0.0; totalIncorrectIncorrect = 0.0; totalIncorrectCorrect = 0.0; numCorrectInstances = 0; numIncorrectInstances = 0; numConfidenceCorrect = 0; numFalsePositive = 0; numFalseNegative = 0; }
public ConfidencePredictingClassifier (Classifier underlyingClassifier, Classifier confidencePredictingClassifier) { super (underlyingClassifier.getInstancePipe()); this.underlyingClassifier = underlyingClassifier; this.confidencePredictingClassifier = confidencePredictingClassifier; // for testing confidence accuracy totalCorrect = 0.0; totalIncorrect = 0.0; totalIncorrectIncorrect = 0.0; totalIncorrectCorrect = 0.0; numCorrectInstances = 0; numIncorrectInstances = 0; numConfidenceCorrect = 0; numFalsePositive = 0; numFalseNegative = 0; }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); try { // load model for inference File modelfile = new File(ReferencesHelper.REFERENCES_RESOURCES + "models/" + modelName); checkArgument(modelfile.exists(), "no modelFile at " + modelName); ObjectInputStream s = new ObjectInputStream(new FileInputStream( modelfile)); classifier = (Classifier) s.readObject(); s.close(); checkArgument(classifier != null); pipes = classifier.getInstancePipe(); } catch (Exception e) { throw new ResourceInitializationException(e); } }
/** * Compute the maxent classifications for unlabeled instances given * by an iterator. * * @param classifier the classifier * @param data the iterator over unlabeled instances * @return the array of classifications for the given instances */ static public Classification[] classify(Classifier classifier, Iterator<Instance> data) { InstanceList unlabeledList = new InstanceList(classifier.getInstancePipe()); unlabeledList.addThruPipe(data); logger.info("# unlabeled instances = " + unlabeledList.size()); List classifications = classifier.classify(unlabeledList); return (Classification[])classifications.toArray(new Classification[]{}); }
/** * Compute the maxent classifications for unlabeled instances given * by an iterator. * * @param classifier the classifier * @param data the iterator over unlabeled instances * @return the array of classifications for the given instances */ static public Classification[] classify(Classifier classifier, Iterator<Instance> data) { InstanceList unlabeledList = new InstanceList(classifier.getInstancePipe()); unlabeledList.addThruPipe(data); logger.info("# unlabeled instances = " + unlabeledList.size()); List classifications = classifier.classify(unlabeledList); return (Classification[])classifications.toArray(new Classification[]{}); }
/** * Compute the maxent classifications for unlabeled instances given * by an iterator. * * @param classifier the classifier * @param data the iterator over unlabeled instances * @return the array of classifications for the given instances */ static public Classification[] classify(Classifier classifier, Iterator<Instance> data) { InstanceList unlabeledList = new InstanceList(classifier.getInstancePipe()); unlabeledList.addThruPipe(data); logger.info("# unlabeled instances = " + unlabeledList.size()); List classifications = classifier.classify(unlabeledList); return (Classification[])classifications.toArray(new Classification[]{}); }
/** * Test a maxent classifier. The data representation is the same as * for training. * * @param classifier the classifier to test * @param data an iterator over labeled instances * @return accuracy on the data */ static public double test(Classifier classifier, Iterator<Instance> data) { InstanceList testList = new InstanceList (classifier.getInstancePipe()); testList.addThruPipe(data); logger.info("# test instances = " + testList.size()); double accuracy = classifier.getAccuracy(testList); return accuracy; }
/** * Test a maxent classifier. The data representation is the same as * for training. * * @param classifier the classifier to test * @param data an iterator over labeled instances * @return accuracy on the data */ static public double test(Classifier classifier, Iterator<Instance> data) { InstanceList testList = new InstanceList (classifier.getInstancePipe()); testList.addThruPipe(data); logger.info("# test instances = " + testList.size()); double accuracy = classifier.getAccuracy(testList); return accuracy; }
/** * Test a maxent classifier. The data representation is the same as * for training. * * @param classifier the classifier to test * @param data an iterator over labeled instances * @return accuracy on the data */ static public double test(Classifier classifier, Iterator<Instance> data) { InstanceList testList = new InstanceList (classifier.getInstancePipe()); testList.addThruPipe(data); logger.info("# test instances = " + testList.size()); double accuracy = classifier.getAccuracy(testList); return accuracy; }
dataOption.value, 0, nameOption.value); Iterator<Instance> iterator = classifier.getInstancePipe().newIteratorFrom(csvIterator); classifier.getInstancePipe().getDataAlphabet().stopGrowth(); classifier.getInstancePipe().getTargetAlphabet().stopGrowth();
classifier.getInstancePipe().newIteratorFrom(fileIterator); classifier.getInstancePipe().getDataAlphabet().stopGrowth(); classifier.getInstancePipe().getTargetAlphabet().stopGrowth();
classifier.getInstancePipe().newIteratorFrom(fileIterator); classifier.getInstancePipe().getDataAlphabet().stopGrowth(); classifier.getInstancePipe().getTargetAlphabet().stopGrowth();
public Matrix predictOne(Matrix input) { Instance instance = new Sample2Instance(input, null, classifier.getAlphabet(), classifier.getLabelAlphabet(), classifier.getInstancePipe(), cumSum); Classification c = classifier.classify(instance); return new Labeling2Matrix(c.getLabeling()); }
.convertFeatsforClassifier(classifier.getInstancePipe(), inst); LOGGER.info("current sentence has this number of token features: " + tokenList.size());
@Override protected void doProcess(JCas jCas) throws AnalysisEngineProcessException { InstanceList instances = new InstanceList(classifierModel.getInstancePipe()); instances.addThruPipe(new Instance(jCas.getDocumentText(), "", "from jcas", null)); Classification classify = classifierModel.classify(instances.get(0)); Metadata md = new Metadata(jCas); md.setKey(metadataKey); md.setValue(classify.getLabeling().getBestLabel().toString()); addToJCasIndex(md); }
@Override protected void doProcess(JCas jCas) throws AnalysisEngineProcessException { InstanceList instances = new InstanceList(classifierModel.getInstancePipe()); instances.addThruPipe(new Instance(jCas.getDocumentText(), "", "from jcas", null)); Classification classify = classifierModel.classify(instances.get(0)); Metadata md = new Metadata(jCas); md.setKey(metadataKey); md.setValue(classify.getLabeling().getBestLabel().toString()); addToJCasIndex(md); }
new Multinomial[] {sports, politics}); Instance inst = c.getInstancePipe().instanceFrom( new Instance (new FeatureVector (fdict, new Object[] {"speech", "win"},
new Multinomial[] {sports, politics}); Instance inst = c.getInstancePipe().instanceFrom( new Instance (new FeatureVector (fdict, new Object[] {"speech", "win"},