当前位置: 首页>>代码示例>>Java>>正文


Java Label.getIndex方法代码示例

本文整理汇总了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);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:35,代码来源:ROCData.java

示例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];
    }
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:30,代码来源:ROCData.java

示例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);
}
 
开发者ID:shalomeir,项目名称:tctm,代码行数:35,代码来源:ROCData.java

示例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];
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:22,代码来源:ROCData.java


注:本文中的cc.mallet.types.Label.getIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。