/** * Get the probability of label with labelIndex for the token at position * @return */ public double labelProb(int position, int labelIndex) { return cliqueTree.prob(position, labelIndex); }
public double[] probsToDoubleArr(int position) { double[] probs = new double[classIndex.size()]; for (int i = 0, sz = classIndex.size(); i < sz; i++) { probs[i] = prob(position, i); } return probs; }
/** Compute the expected counts for this document, which we will need to compute the derivative. */ protected void documentExpectedCounts(double[][] E, int[][][] docData, double[][][] featureVal3DArr, CRFCliqueTree<String> cliqueTree) { // iterate over the positions in this document for (int i = 0; i < docData.length; i++) { // for each possible clique at this position for (int j = 0; j < docData[i].length; j++) { Index<CRFLabel> labelIndex = labelIndices.get(j); // for each possible labeling for that clique for (int k = 0, liSize = labelIndex.size(); k < liSize; k++) { int[] label = labelIndex.get(k).getLabel(); double p = cliqueTree.prob(i, label); // probability of these labels occurring in this clique with these features for (int n = 0; n < docData[i][j].length; n++) { double fVal = 1.0; if (j == 0 && featureVal3DArr != null) { // j == 0 because only node features gets feature values fVal = featureVal3DArr[i][j][n]; } E[docData[i][j][n]][k] += p * fVal; } } } } }
public List<Counter<String>> zeroOrderProbabilities(List<IN> document) { List<Counter<String>> ret = new ArrayList<>(); Triple<int[][][], int[], double[][][]> p = documentToDataAndLabels(document); CRFCliqueTree<String> cliqueTree = getCliqueTree(p); for (int i = 0; i < cliqueTree.length(); i++) { Counter<String> ctr = new ClassicCounter<>(); for (String label : classIndex) { int index = classIndex.indexOf(label); double prob = cliqueTree.prob(i, index); ctr.setCount(label, prob); } ret.add(ctr); } return ret; }
public Counter<E> probs(int position) { Counter<E> c = new ClassicCounter<>(); for (int i = 0, sz = classIndex.size(); i < sz; i++) { E label = classIndex.get(i); c.incrementCount(label, prob(position, i)); } return c; }
public GeneralizedCounter<E> probs(int position, int window) { GeneralizedCounter<E> gc = new GeneralizedCounter<>(window); int[] labels = new int[window]; // cdm july 2005: below array initialization isn't necessary: JLS (3rd ed.) // 4.12.5 // Arrays.fill(labels, 0); OUTER: while (true) { List<E> labelsList = intArrayToListE(labels); gc.incrementCount(labelsList, prob(position, labels)); for (int i = 0; i < labels.length; i++) { labels[i]++; if (labels[i] < numClasses) { break; } if (i == labels.length - 1) { break OUTER; } labels[i] = 0; } } return gc; }
int index = classIndex.indexOf(label); double prob = cliqueTree.prob(i, index); if (prob > maxProb) { bestClass = label;
double PtYYp = cliqueTree.prob(i, label); double PtYYpTimesOneMinusPtYYp = PtYYp * (1.0 - PtYYp); double oneMinus2PtYYp = (1.0 - 2 * PtYYp);
double p = cliqueTree.prob(i, label); // probability of these labels occurring in this clique with these features if (dropoutApprox) increScore(EForADocPosAtI, fIndex, k, fVal * p);
double p = cliqueTree.prob(i, label); // probability of these labels occurring in this clique with these features for (int lopIter = 0; lopIter < numLopExpert; lopIter++) { Set<Integer> indicesSet = featureIndicesSetArray.get(lopIter);
double p = cliqueTree.prob(i, label); // probability of these labels occurring in this clique with these features double[] Uk2 = null; double[] eUK = null;
double p = cliqueTree.prob(i, label); // probability of these labels occurring in this clique with these features if (j == 0) { // for node features double[] Uk = null;
/** * Get the probability of label with labelIndex for the token at position * @return */ public double labelProb(int position, int labelIndex) { return cliqueTree.prob(position, labelIndex); }
public double[] probsToDoubleArr(int position) { double[] probs = new double[classIndex.size()]; for (int i = 0, sz = classIndex.size(); i < sz; i++) { probs[i] = prob(position, i); } return probs; }
public double[] probsToDoubleArr(int position) { double[] probs = new double[classIndex.size()]; for (int i = 0, sz = classIndex.size(); i < sz; i++) { probs[i] = prob(position, i); } return probs; }
public List<Counter<String>> zeroOrderProbabilities(List<IN> document) { List<Counter<String>> ret = new ArrayList<>(); Triple<int[][][], int[], double[][][]> p = documentToDataAndLabels(document); CRFCliqueTree<String> cliqueTree = getCliqueTree(p); for (int i = 0; i < cliqueTree.length(); i++) { Counter<String> ctr = new ClassicCounter<>(); for (String label : classIndex) { int index = classIndex.indexOf(label); double prob = cliqueTree.prob(i, index); ctr.setCount(label, prob); } ret.add(ctr); } return ret; }
public Counter<E> probs(int position) { Counter<E> c = new ClassicCounter<>(); for (int i = 0, sz = classIndex.size(); i < sz; i++) { E label = classIndex.get(i); c.incrementCount(label, prob(position, i)); } return c; }
public Counter<E> probs(int position) { Counter<E> c = new ClassicCounter<E>(); for (int i = 0, sz = classIndex.size(); i < sz; i++) { E label = classIndex.get(i); c.incrementCount(label, prob(position, i)); } return c; }
public ClassicCounter probs(int position) { ClassicCounter c = new ClassicCounter(); for (int i = 0; i < classIndex.size(); i++) { Object label = classIndex.get(i); c.incrementCount(label, prob(position, i)); } return c; }