/** * Returns the probability for the given labels (indexed using classIndex), * where the last label corresponds to the label at the specified position. * For instance if you called prob(5, {1,2,3}) it will return the marginal * prob that the label at position 3 is 1, the label at position 4 is 2 and * the label at position 5 is 3. */ public double prob(int position, int[] labels) { return Math.exp(logProb(position, labels)); }
/** * returns the probability for the given labels, where the last label * corresponds to the label at the specified position. For instance if you * called logProb(5, {"O", "PER", "ORG"}) it will return the marginal prob * that the label at position 3 is "O", the label at position 4 is "PER" and * the label at position 5 is "ORG". */ public double prob(int position, E[] labels) { return Math.exp(logProb(position, labels)); }
public double prob(int position, E label) { return Math.exp(logProb(position, label)); }
public double prob(int position, int label) { return Math.exp(logProb(position, label)); }
/** * returns the log probability for the given labels, where the last label * corresponds to the label at the specified position. For instance if you * called logProb(5, {"O", "PER", "ORG"}) it will return the marginal log prob * that the label at position 3 is "O", the label at position 4 is "PER" and * the label at position 5 is "ORG". */ public double logProb(int position, E[] labels) { return logProb(position, objectArrayToIntArray(labels)); }
public double logProb(int position, E label) { return logProb(position, classIndex.indexOf(label)); }
public double[] logProbsToDoubleArr(int position) { double[] probs = new double[classIndex.size()]; for (int i = 0, sz = classIndex.size(); i < sz; i++) { probs[i] = logProb(position, i); } return probs; }
/** * Takes a {@link List} of something that extends {@link CoreMap} and prints * the factor table at each point. * * @param document A {@link List} of something that extends {@link CoreMap}. */ @SuppressWarnings("WeakerAccess") public void printFactorTableDocument(List<IN> document) { CRFCliqueTree<String> cliqueTree = getCliqueTree(document); FactorTable[] factorTables = cliqueTree.getFactorTables(); StringBuilder sb = new StringBuilder(); for (int i=0; i < factorTables.length; i++) { IN wi = document.get(i); sb.append(wi.get(CoreAnnotations.TextAnnotation.class)); sb.append('\t'); FactorTable table = factorTables[i]; for (int j = 0; j < table.size(); j++) { int[] arr = table.toArray(j); sb.append(classIndex.get(arr[0])); sb.append(':'); sb.append(classIndex.get(arr[1])); sb.append(':'); sb.append(cliqueTree.logProb(i, arr)); sb.append(' '); } sb.append('\n'); } System.out.print(sb); }
public Counter<E> logProbs(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, logProb(position, i)); } return c; }
public GeneralizedCounter<E> logProbs(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, logProb(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; }
for (int l2 = 0; l2 < numClasses; l2++) { labelPair[1] = l2; double prob = cTree.logProb(i, labelPair);
public double[][] logProbTable() { double[][] result = new double[length()][classIndex.size()]; for (int i = 0; i < length(); i++) { result[i] = new double[classIndex.size()]; for (int j = 0; j < classIndex.size(); j++) { result[i][j] = logProb(i, j); } } return result; }
/** * Returns the probability for the given labels (indexed using classIndex), * where the last label corresponds to the label at the specified position. * For instance if you called prob(5, {1,2,3}) it will return the marginal * prob that the label at position 3 is 1, the label at position 4 is 2 and * the label at position 5 is 3. */ public double prob(int position, int[] labels) { return Math.exp(logProb(position, labels)); }
/** * returns the probability for the given labels, where the last label * corresponds to the label at the specified position. For instance if you * called logProb(5, {"O", "PER", "ORG"}) it will return the marginal prob * that the label at position 3 is "O", the label at position 4 is "PER" and * the label at position 5 is "ORG". */ public double prob(int position, E[] labels) { return Math.exp(logProb(position, labels)); }
/** * Returns the probability for the given labels (indexed using classIndex), * where the last label corresponds to the label at the specified position. * For instance if you called prob(5, {1,2,3}) it will return the marginal * prob that the label at position 3 is 1, the label at position 4 is 2 and * the label at position 5 is 3. */ public double prob(int position, int[] labels) { return Math.exp(logProb(position, labels)); }
/** * returns the probability for the given labels, where the * last label corresponds to the label at the specified position. For instance if you called * logProb(5, {"O", "PER", "ORG"}) it will return the marginal prob that the label at position * 3 is "O", the label at position 4 is "PER" and the label at position 5 is "ORG". */ public double prob(int position, Object[] labels) { return Math.exp(logProb(position, labels)); }
/** * returns the log probability for the given labels, where the last label * corresponds to the label at the specified position. For instance if you * called logProb(5, {"O", "PER", "ORG"}) it will return the marginal log prob * that the label at position 3 is "O", the label at position 4 is "PER" and * the label at position 5 is "ORG". */ public double logProb(int position, E[] labels) { return logProb(position, objectArrayToIntArray(labels)); }
public double[] logProbsToDoubleArr(int position) { double[] probs = new double[classIndex.size()]; for (int i = 0, sz = classIndex.size(); i < sz; i++) { probs[i] = logProb(position, i); } return probs; }
public Counter<E> logProbs(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, logProb(position, i)); } return c; }
public double[][] logProbTable() { double[][] result = new double[length()][classIndex.size()]; for (int i = 0; i < length(); i++) { result[i] = new double[classIndex.size()]; for (int j = 0; j < classIndex.size(); j++) { result[i][j] = logProb(i, j); } } return result; }