private static void smoothDistribution(double [] dist) { //perform Laplace smoothing double epsilon = 1e-6; for(int i = 0; i < dist.length; i++) dist[i] += epsilon; ArrayMath.normalize(dist); }
ArrayMath.normalize(geFeature2EmpiricalDist[n]); smoothDistribution(geFeature2EmpiricalDist[n]);
/** * Samples each label in turn from left to right. * * @return an array containing the int tags of the best sequence */ @Override public int[] bestSequence(SequenceModel ts) { // Also allocate space for rightWindow, just in case sequence model uses // it, even though this implementation doesn't. Probably it shouldn't, // or the left-to-right sampling is invalid, but our test classes do. int[] sample = new int[ts.length()+ts.leftWindow()+ts.rightWindow()]; for (int pos = ts.leftWindow(); pos < sample.length - ts.rightWindow(); pos++) { double[] scores = ts.scoresOf(sample, pos); for (int i = 0; i < scores.length; i++) { scores[i] = Math.exp(scores[i]); } ArrayMath.normalize(scores); int l = ArrayMath.sampleFromDistribution(scores); sample[pos] = ts.getPossibleValues(pos)[l]; } return sample; }
ArrayMath.normalize(row);
private static void smoothDistribution(double [] dist) { //perform Laplace smoothing double epsilon = 1e-6; for(int i = 0; i < dist.length; i++) dist[i] += epsilon; ArrayMath.normalize(dist); }
private void smoothDistribution(double [] dist){ //perform Laplace smoothing double epsilon = 1e-6; for(int i = 0; i < dist.length; i++) dist[i] += epsilon; ArrayMath.normalize(dist); }
private static void smoothDistribution(double [] dist) { //perform Laplace smoothing double epsilon = 1e-6; for(int i = 0; i < dist.length; i++) dist[i] += epsilon; ArrayMath.normalize(dist); }
ArrayMath.normalize(geFeature2EmpiricalDist[n]); smoothDistribution(geFeature2EmpiricalDist[n]);
ArrayMath.normalize(geFeature2EmpiricalDist[n]); smoothDistribution(geFeature2EmpiricalDist[n]);
ArrayMath.normalize(geFeature2EmpiricalDist[n]); smoothDistribution(geFeature2EmpiricalDist[n]);
/** * Runs the Viterbi algorithm on the sequence model given by the TagScorer * in order to find the best sequence. * @return an array containing the int tags of the best sequence */ public int[] bestSequence(SequenceModel ts) { int[] sample = new int[ts.length()+ts.leftWindow()]; for (int pos = ts.leftWindow(); pos < sample.length; pos++) { double[] scores = ts.scoresOf(sample, pos); double total = 0.0; for (int i = 0; i < scores.length; i++) { scores[i] = Math.exp(scores[i]); } ArrayMath.normalize(scores); int l = ArrayMath.sampleFromDistribution(scores); sample[pos] = ts.getPossibleValues(pos)[l]; } return sample; }
/** * Samples each label in turn from left to right. * * @return an array containing the int tags of the best sequence */ @Override public int[] bestSequence(SequenceModel ts) { // Also allocate space for rightWindow, just in case sequence model uses // it, even though this implementation doesn't. Probably it shouldn't, // or the left-to-right sampling is invalid, but our test classes do. int[] sample = new int[ts.length()+ts.leftWindow()+ts.rightWindow()]; for (int pos = ts.leftWindow(); pos < sample.length - ts.rightWindow(); pos++) { double[] scores = ts.scoresOf(sample, pos); for (int i = 0; i < scores.length; i++) { scores[i] = Math.exp(scores[i]); } ArrayMath.normalize(scores); int l = ArrayMath.sampleFromDistribution(scores); sample[pos] = ts.getPossibleValues(pos)[l]; } return sample; }
ArrayMath.normalize(row);
/** * Samples each label in turn from left to right. * * @return an array containing the int tags of the best sequence */ @Override public int[] bestSequence(SequenceModel ts) { // Also allocate space for rightWindow, just in case sequence model uses // it, even though this implementation doesn't. Probably it shouldn't, // or the left-to-right sampling is invalid, but our test classes do. int[] sample = new int[ts.length()+ts.leftWindow()+ts.rightWindow()]; for (int pos = ts.leftWindow(); pos < sample.length - ts.rightWindow(); pos++) { double[] scores = ts.scoresOf(sample, pos); for (int i = 0; i < scores.length; i++) { scores[i] = Math.exp(scores[i]); } ArrayMath.normalize(scores); int l = ArrayMath.sampleFromDistribution(scores); sample[pos] = ts.getPossibleValues(pos)[l]; } return sample; }
ArrayMath.normalize(confusionMatrix[i]);
ArrayMath.normalize(row);