本文整理汇总了Java中cc.mallet.types.Label.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Label.getIndex方法的具体用法?Java Label.getIndex怎么用?Java Label.getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.mallet.types.Label
的用法示例。
在下文中一共展示了Label.getIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrecisionForScore
import cc.mallet.types.Label; //导入方法依赖的package包/类
/**
* Gets the precision for a specified label and score. This differs from
* {@link ROCData.getPrecision(Label, double)} in that it is the precision
* for only scores falling in the one score value, not for all scores
* above the threshold.
*
* If data was not collected for the exact threshold specified, then results
* will for the highest threshold <= the specified threshold will be
* returned.
*
* @param label Label to get precision for
* @param threshold Threshold to get precision for
* @return Precision for specified label and score
*/
public double getPrecisionForScore(Label label, double score) {
final int[][] buckets = this.counts[label.getIndex()];
int index = Arrays.binarySearch(this.thresholds, score);
if (index < 0) {
index = (-index) - 2;
}
final double tp;
final double fp;
if (index == this.thresholds.length - 1) {
tp = buckets[index][TRUE_POSITIVE];
fp = buckets[index][FALSE_POSITIVE];
} else {
tp = buckets[index][TRUE_POSITIVE] - buckets[index + 1][TRUE_POSITIVE];
fp = buckets[index][FALSE_POSITIVE] - buckets[index + 1][FALSE_POSITIVE];
}
return (double) tp / (double) (tp + fp);
}
示例2: setCounts
import cc.mallet.types.Label; //导入方法依赖的package包/类
/**
* Sets the raw counts for a specified label and threshold.
*
* If data is not collected for the exact threshold specified, then counts
* for the highest threshold <= the specified threshold will be set.
*
* @param label Label to get counts for
* @param threshold Threshold to get counts for
* @param newCounts New count values for the label and threshold
* @see #TRUE_POSITIVE
* @see #FALSE_POSITIVE
* @see #FALSE_NEGATIVE
* @see #TRUE_NEGATIVE
*/
public void setCounts(Label label, double threshold, int[] newCounts) {
int index = Arrays.binarySearch(this.thresholds, threshold);
if (index < 0) {
index = (-index) - 2;
}
final int[] oldCounts = this.counts[label.getIndex()][index];
if (newCounts.length != oldCounts.length) {
throw new IllegalArgumentException ("Array of counts must contain " + oldCounts.length + " elements.");
}
for (int i = 0; i < oldCounts.length; i++) {
oldCounts[i] = newCounts[i];
}
}
示例3: getPrecisionForScore
import cc.mallet.types.Label; //导入方法依赖的package包/类
/**
* Gets the precision for a specified label and score. This differs from
* {@link cc.mallet.types.ROCData.getPrecision( cc.mallet.types.Label, double)} in that it is the precision
* for only scores falling in the one score value, not for all scores
* above the threshold.
*
* If data was not collected for the exact threshold specified, then results
* will for the highest threshold <= the specified threshold will be
* returned.
*
* @param label Label to get precision for
* @param threshold Threshold to get precision for
* @return Precision for specified label and score
*/
public double getPrecisionForScore(Label label, double score) {
final int[][] buckets = this.counts[label.getIndex()];
int index = Arrays.binarySearch(this.thresholds, score);
if (index < 0) {
index = (-index) - 2;
}
final double tp;
final double fp;
if (index == this.thresholds.length - 1) {
tp = buckets[index][TRUE_POSITIVE];
fp = buckets[index][FALSE_POSITIVE];
} else {
tp = buckets[index][TRUE_POSITIVE] - buckets[index + 1][TRUE_POSITIVE];
fp = buckets[index][FALSE_POSITIVE] - buckets[index + 1][FALSE_POSITIVE];
}
return (double) tp / (double) (tp + fp);
}
示例4: getCounts
import cc.mallet.types.Label; //导入方法依赖的package包/类
/**
* Gets the raw counts for a specified label and threshold.
*
* If data was not collected for the exact threshold specified, then results
* for the highest threshold <= the specified threshold will be returned.
*
* @param label Label to get counts for
* @param threshold Threshold to get counts for
* @see #TRUE_POSITIVE
* @see #FALSE_POSITIVE
* @see #FALSE_NEGATIVE
* @see #TRUE_NEGATIVE
* @return Array of raw counts for specified label and threshold
*/
public int[] getCounts(Label label, double threshold) {
int index = Arrays.binarySearch(this.thresholds, threshold);
if (index < 0) {
index = (-index) - 2;
}
return this.counts[label.getIndex()][index];
}