當前位置: 首頁>>代碼示例>>Java>>正文


Java Evaluation.fMeasure方法代碼示例

本文整理匯總了Java中weka.classifiers.Evaluation.fMeasure方法的典型用法代碼示例。如果您正苦於以下問題:Java Evaluation.fMeasure方法的具體用法?Java Evaluation.fMeasure怎麽用?Java Evaluation.fMeasure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在weka.classifiers.Evaluation的用法示例。


在下文中一共展示了Evaluation.fMeasure方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printMeasures

import weka.classifiers.Evaluation; //導入方法依賴的package包/類
public static void printMeasures(final Evaluation eval) {

    final List<String> cat = EntityClassMap.entityClasses;
    for (final String cl : EntityClassMap.entityClasses) {

      final double f1 = eval.fMeasure(cat.indexOf(cl));
      final double p = eval.precision(cat.indexOf(cl));
      final double r = eval.recall(cat.indexOf(cl));

      LOG.info("=== classes ===");
      LOG.info("class: " + cl);
      LOG.info("fMeasure: " + f1);
      LOG.info("precision: " + p);
      LOG.info("recall: " + r);
    }
  }
 
開發者ID:dice-group,項目名稱:FOX,代碼行數:17,代碼來源:CrossValidation.java

示例2: computeSingleRunResults

import weka.classifiers.Evaluation; //導入方法依賴的package包/類
public void computeSingleRunResults(MethodEvaluation methodEvaluation)
{
    Evaluation evaluation = methodEvaluation.getEvaluation();
    int hamIndex = HAM.ordinal();
    int spamIndex = SPAM.ordinal();

    Double hamPrecision = 100.0 * evaluation.precision(hamIndex);
    Double spamPrecision = 100.0 * evaluation.precision(spamIndex);
    Double weightedPrecision = 100.0 * evaluation.weightedPrecision();

    Double hamRecall = 100.0 * evaluation.recall(hamIndex);
    Double spamRecall = 100.0 * evaluation.recall(spamIndex);
    Double weightedRecall = 100.0 * evaluation.weightedRecall();

    Double hamAreaUnderPRC = 100.0 * evaluation.areaUnderPRC(hamIndex);
    Double spamAreaUnderPRC = 100.0 * evaluation.areaUnderPRC(spamIndex);
    Double weightedAreaUnderPRC = 100.0 * evaluation.weightedAreaUnderPRC();

    Double hamAreaUnderROC = 100.0 * evaluation.areaUnderROC(hamIndex);
    Double spamAreaUnderROC = 100.0 * evaluation.areaUnderROC(spamIndex);
    Double weightedAreaUnderROC = 100.0 * evaluation.weightedAreaUnderROC();

    Double hamFMeasure = 100.0 * evaluation.fMeasure(hamIndex);
    Double spamFMeasure = 100.0 * evaluation.fMeasure(spamIndex);
    Double weightedFMeasure = 100.0 * evaluation.weightedFMeasure();

    Double trainTime = (double) (methodEvaluation.getTrainEnd() - methodEvaluation.getTrainStart());

    Double testTime = (double) (methodEvaluation.getTestEnd() - methodEvaluation.getTestStart());

    addSingleRunResult(Metric.HAM_PRECISION, hamPrecision);
    addSingleRunResult(Metric.SPAM_PRECISION, spamPrecision);
    addSingleRunResult(Metric.WEIGHTED_PRECISION, weightedPrecision);
    addSingleRunResult(Metric.HAM_RECALL, hamRecall);
    addSingleRunResult(Metric.SPAM_RECALL, spamRecall);
    addSingleRunResult(Metric.WEIGHTED_RECALL, weightedRecall);
    addSingleRunResult(Metric.HAM_AREA_UNDER_PRC, hamAreaUnderPRC);
    addSingleRunResult(Metric.SPAM_AREA_UNDER_PRC, spamAreaUnderPRC);
    addSingleRunResult(Metric.WEIGHTED_AREA_UNDER_PRC, weightedAreaUnderPRC);
    addSingleRunResult(Metric.HAM_AREA_UNDER_ROC, hamAreaUnderROC);
    addSingleRunResult(Metric.SPAM_AREA_UNDER_ROC, spamAreaUnderROC);
    addSingleRunResult(Metric.WEIGHTED_AREA_UNDER_ROC, weightedAreaUnderROC);
    addSingleRunResult(Metric.HAM_F_MEASURE, hamFMeasure);
    addSingleRunResult(Metric.SPAM_F_MEASURE, spamFMeasure);
    addSingleRunResult(Metric.WEIGHTED_F_MEASURE, weightedFMeasure);
    addSingleRunResult(Metric.TRAIN_TIME, trainTime);
    addSingleRunResult(Metric.TEST_TIME, testTime);
}
 
開發者ID:marcelovca90,項目名稱:anti-spam-weka-gui,代碼行數:49,代碼來源:ExperimentHelper.java


注:本文中的weka.classifiers.Evaluation.fMeasure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。