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


Java Evaluation.pctCorrect方法代码示例

本文整理汇总了Java中weka.classifiers.Evaluation.pctCorrect方法的典型用法代码示例。如果您正苦于以下问题:Java Evaluation.pctCorrect方法的具体用法?Java Evaluation.pctCorrect怎么用?Java Evaluation.pctCorrect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.classifiers.Evaluation的用法示例。


在下文中一共展示了Evaluation.pctCorrect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluate

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
public static void evaluate(Classifier clf, Instances data, double minPerfomance)
    throws Exception {
  Instances[] split = TestUtil.splitTrainTest(data);

  Instances train = split[0];
  Instances test = split[1];

  clf.buildClassifier(train);
  Evaluation trainEval = new Evaluation(train);
  trainEval.evaluateModel(clf, train);

  Evaluation testEval = new Evaluation(train);
  testEval.evaluateModel(clf, test);

  final double testPctCorrect = testEval.pctCorrect();
  final double trainPctCorrect = trainEval.pctCorrect();

  log.info("Train: {}, Test: {}", trainPctCorrect, testPctCorrect);
  boolean success =
      testPctCorrect > minPerfomance && trainPctCorrect > minPerfomance;
  Assert.assertTrue(success);
}
 
开发者ID:Waikato,项目名称:wekaDeeplearning4j,代码行数:23,代码来源:StabilityTest.java

示例2: getMetricScore

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
public double getMetricScore(Evaluation eval, PerformanceMetric metric) {
    if (metric.getName().equals("accuracy")) {
        return eval.pctCorrect();
    } else if (metric.getName().equals("auc")) {
        return eval.areaUnderROC(0);
    } else if (metric.getName().equals("rmse")) {
        return eval.rootMeanSquaredError();
    } else if (metric.getName().equals("mae")) {
        return eval.meanAbsoluteError();
    } else if (metric.getName().equals("logLoss")) {
        return eval.SFMeanSchemeEntropy();
    } else if (metric.getName().equals("rmsle")) {
        return eval.rootMeanSquaredLogError();
    }
    throw new RuntimeException(this.getClass().getName() + "impl me please: " + metric.getName());
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:17,代码来源:WekaApacheEngine.java

示例3: getCrossValidation

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
/**
 * @param cls
 * @param data
 * @param folds
 * @return [0] = pctCorrect, [1] = pctIncorrect
 * @throws Exception
 */
public double[] getCrossValidation(Classifier cls, Instances data, int folds) throws Exception {

	cls.buildClassifier(data);

	Classifier copy = Classifier.makeCopy(cls);
	double[] results = new double[2];
	for (int n = 0; n < folds; n++) {
		Instances train = data.trainCV(folds, n);
		Instances test = data.testCV(folds, n);

		// CSVSaver saver = new CSVSaver();
		// saver.setInstances(train);
		// saver.setFile(new File("../data.csv"));
		// saver.writeBatch();

		cls.buildClassifier(train);
		Evaluation eval = new Evaluation(data);
		eval.evaluateModel(cls, test);
		results[0] = results[0] + (eval.pctCorrect() / 100);
		results[1] = results[1] + (eval.pctIncorrect() / 100);
	}

	cls = copy;
	results[0] = results[0] / folds;
	results[1] = results[1] / folds;
	return results;
}
 
开发者ID:gsi-upm,项目名称:BARMAS,代码行数:35,代码来源:ClassifiersValidation.java

示例4: getValidation

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
/**
 * @param cls
 * @param trainingData
 * @param testData
 * @return [0] = pctCorrect, [1] = pctIncorrect
 * @throws Exception
 */
public double[] getValidation(Classifier cls, Instances trainingData, Instances testData)
		throws Exception {

	cls.buildClassifier(trainingData);

	Evaluation eval = new Evaluation(trainingData);
	eval.evaluateModel(cls, testData);

	double[] results = new double[2];
	results[0] = eval.pctCorrect() / 100;
	results[1] = eval.pctIncorrect() / 100;
	return results;
}
 
开发者ID:gsi-upm,项目名称:BARMAS,代码行数:21,代码来源:ClassifiersValidation.java

示例5: crossValidate

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
public double crossValidate(Classifier cls, Instances data)	throws Exception {

		double pctCorrect;
		
		Evaluation eval = new Evaluation(data);
		StringBuffer forPredictionsPrinting = new StringBuffer();
		PlainText classifierOutput = new PlainText();

		classifierOutput.setBuffer(forPredictionsPrinting);
		weka.core.Range attsToOutput = null;
		Boolean outputDistribution = new Boolean(true);
		classifierOutput.setOutputDistribution(true);

		eval.crossValidateModel(cls, data, 10, new Random(1), classifierOutput,
				attsToOutput, outputDistribution);

		System.out.println("Number of correct classified " + eval.correct());
		System.out.println("Percentage of correct classified "
				+ eval.pctCorrect());
		System.out.println(eval.toClassDetailsString());
		System.out.println(eval.toMatrixString());

		System.out.println(eval.toSummaryString());
		pctCorrect = eval.pctCorrect()/100;
		
		return pctCorrect;
	}
 
开发者ID:socialsensor,项目名称:computational-verification,代码行数:28,代码来源:VerifHandler.java

示例6: getScore

import weka.classifiers.Evaluation; //导入方法依赖的package包/类
public float getScore(Evaluation eval, Instances testingData){
    return (float)(100 - eval.pctCorrect()); 
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:4,代码来源:ClassifierResult.java


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