List of usage examples for weka.classifiers Evaluation falsePositiveRate
public double falsePositiveRate(int classIndex)
From source file:adams.flow.core.EvaluationHelper.java
License:Open Source License
/** * Returns a statistical value from the evaluation object. * * @param eval the evaluation object to get the value from * @param statistic the type of value to return * @param classIndex the class label index, for statistics like AUC * @return the determined value, Double.NaN if not found * @throws Exception if evaluation fails *///from w w w .ja va 2 s . com public static double getValue(Evaluation eval, EvaluationStatistic statistic, int classIndex) throws Exception { switch (statistic) { case NUMBER_CORRECT: return eval.correct(); case NUMBER_INCORRECT: return eval.incorrect(); case NUMBER_UNCLASSIFIED: return eval.unclassified(); case PERCENT_CORRECT: return eval.pctCorrect(); case PERCENT_INCORRECT: return eval.pctIncorrect(); case PERCENT_UNCLASSIFIED: return eval.pctUnclassified(); case KAPPA_STATISTIC: return eval.kappa(); case MEAN_ABSOLUTE_ERROR: return eval.meanAbsoluteError(); case ROOT_MEAN_SQUARED_ERROR: return eval.rootMeanSquaredError(); case RELATIVE_ABSOLUTE_ERROR: return eval.relativeAbsoluteError(); case ROOT_RELATIVE_SQUARED_ERROR: return eval.rootRelativeSquaredError(); case CORRELATION_COEFFICIENT: return eval.correlationCoefficient(); case SF_PRIOR_ENTROPY: return eval.SFPriorEntropy(); case SF_SCHEME_ENTROPY: return eval.SFSchemeEntropy(); case SF_ENTROPY_GAIN: return eval.SFEntropyGain(); case SF_MEAN_PRIOR_ENTROPY: return eval.SFMeanPriorEntropy(); case SF_MEAN_SCHEME_ENTROPY: return eval.SFMeanSchemeEntropy(); case SF_MEAN_ENTROPY_GAIN: return eval.SFMeanEntropyGain(); case KB_INFORMATION: return eval.KBInformation(); case KB_MEAN_INFORMATION: return eval.KBMeanInformation(); case KB_RELATIVE_INFORMATION: return eval.KBRelativeInformation(); case TRUE_POSITIVE_RATE: return eval.truePositiveRate(classIndex); case NUM_TRUE_POSITIVES: return eval.numTruePositives(classIndex); case FALSE_POSITIVE_RATE: return eval.falsePositiveRate(classIndex); case NUM_FALSE_POSITIVES: return eval.numFalsePositives(classIndex); case TRUE_NEGATIVE_RATE: return eval.trueNegativeRate(classIndex); case NUM_TRUE_NEGATIVES: return eval.numTrueNegatives(classIndex); case FALSE_NEGATIVE_RATE: return eval.falseNegativeRate(classIndex); case NUM_FALSE_NEGATIVES: return eval.numFalseNegatives(classIndex); case IR_PRECISION: return eval.precision(classIndex); case IR_RECALL: return eval.recall(classIndex); case F_MEASURE: return eval.fMeasure(classIndex); case MATTHEWS_CORRELATION_COEFFICIENT: return eval.matthewsCorrelationCoefficient(classIndex); case AREA_UNDER_ROC: return eval.areaUnderROC(classIndex); case AREA_UNDER_PRC: return eval.areaUnderPRC(classIndex); case WEIGHTED_TRUE_POSITIVE_RATE: return eval.weightedTruePositiveRate(); case WEIGHTED_FALSE_POSITIVE_RATE: return eval.weightedFalsePositiveRate(); case WEIGHTED_TRUE_NEGATIVE_RATE: return eval.weightedTrueNegativeRate(); case WEIGHTED_FALSE_NEGATIVE_RATE: return eval.weightedFalseNegativeRate(); case WEIGHTED_IR_PRECISION: return eval.weightedPrecision(); case WEIGHTED_IR_RECALL: return eval.weightedRecall(); case WEIGHTED_F_MEASURE: return eval.weightedFMeasure(); case WEIGHTED_MATTHEWS_CORRELATION_COEFFICIENT: return eval.weightedMatthewsCorrelation(); case WEIGHTED_AREA_UNDER_ROC: return eval.weightedAreaUnderROC(); case WEIGHTED_AREA_UNDER_PRC: return eval.weightedAreaUnderPRC(); case UNWEIGHTED_MACRO_F_MEASURE: return eval.unweightedMacroFmeasure(); case UNWEIGHTED_MICRO_F_MEASURE: return eval.unweightedMicroFmeasure(); case BIAS: return eval.getPluginMetric(Bias.class.getName()).getStatistic(Bias.NAME); case RSQUARED: return eval.getPluginMetric(RSquared.class.getName()).getStatistic(RSquared.NAME); case SDR: return eval.getPluginMetric(SDR.class.getName()).getStatistic(SDR.NAME); case RPD: return eval.getPluginMetric(RPD.class.getName()).getStatistic(RPD.NAME); default: throw new IllegalArgumentException("Unhandled statistic field: " + statistic); } }
From source file:algoritmogeneticocluster.Cromossomo.java
private double getMicroAverage(Evaluation eval, Instances data) { double TP = 0; double TP_plus_FP = 0; double TP_plus_FN = 0; double microPrecision; double microRecall; double microMeasure; for (int i = 0; i < data.numClasses(); i++) { TP += eval.truePositiveRate(i);//from ww w . ja v a 2s . com TP_plus_FP += eval.truePositiveRate(i) + eval.falsePositiveRate(i); TP_plus_FN += eval.truePositiveRate(i) + eval.falseNegativeRate(i); } microPrecision = TP / TP_plus_FP; microRecall = TP / TP_plus_FN; microMeasure = (microPrecision * microRecall * 2) / (microPrecision + microRecall); //System.out.println("microMeasure: " + microMeasure); return microMeasure; }
From source file:meddle.TrainModelByDomainOS.java
License:Open Source License
/** * Do evalution on trained classifier/model, including the summary, false * positive/negative rate, AUC, running time * * @param j48//from ww w. jav a 2s . c o m * - the trained classifier * @param domain * - the domain name */ public static MetaEvaluationMeasures doEvaluation(Classifier classifier, String domainOS, Instances tras, MetaEvaluationMeasures mem) { try { Evaluation evaluation = new Evaluation(tras); evaluation.crossValidateModel(classifier, tras, 10, new Random(1)); mem.numInstance = evaluation.numInstances(); double M = evaluation.numTruePositives(1) + evaluation.numFalseNegatives(1); mem.numPositive = (int) M; mem.AUC = evaluation.areaUnderROC(1); mem.numCorrectlyClassified = (int) evaluation.correct(); mem.accuracy = 1.0 * mem.numCorrectlyClassified / mem.numInstance; mem.falseNegativeRate = evaluation.falseNegativeRate(1); mem.falsePositiveRate = evaluation.falsePositiveRate(1); mem.fMeasure = evaluation.fMeasure(1); double[][] cmMatrix = evaluation.confusionMatrix(); mem.confusionMatrix = cmMatrix; mem.TP = evaluation.numTruePositives(1); mem.TN = evaluation.numTrueNegatives(1); mem.FP = evaluation.numFalsePositives(1); mem.FN = evaluation.numFalseNegatives(1); } catch (Exception e) { e.printStackTrace(); } return mem; }