/** * Returns the false positive rate for a given label * * @param classLabel the label * @param edgeCase What to output in case of 0/0 * @return fpr as a double */ public double falsePositiveRate(int classLabel, double edgeCase) { double fpCount = falsePositives(classLabel); double tnCount = trueNegatives(classLabel); return EvaluationUtils.falsePositiveRate((long) fpCount, (long) tnCount, edgeCase); }
/** * Returns the false positive rate for a given label * * @param classLabel the label * @param edgeCase What to output in case of 0/0 * @return fpr as a double */ public double falsePositiveRate(int classLabel, double edgeCase) { double fpCount = falsePositives.getCount(classLabel); double tnCount = trueNegatives.getCount(classLabel); return EvaluationUtils.falsePositiveRate((long) fpCount, (long) tnCount, edgeCase); }
/** * Calculate the average false positive rate across all classes. Can specify whether macro or micro averaging should be used * * @param averaging Averaging method - macro or micro * @return Average false positive rate */ public double falsePositiveRate(EvaluationAveraging averaging) { int nClasses = confusion().getClasses().size(); if (averaging == EvaluationAveraging.Macro) { double macroFPR = 0.0; for (int i = 0; i < nClasses; i++) { macroFPR += falsePositiveRate(i); } macroFPR /= nClasses; return macroFPR; } else if (averaging == EvaluationAveraging.Micro) { long fpCount = 0; long tnCount = 0; for (int i = 0; i < nClasses; i++) { fpCount += falsePositives.getCount(i); tnCount += trueNegatives.getCount(i); } return EvaluationUtils.falsePositiveRate(fpCount, tnCount, DEFAULT_EDGE_VALUE); } else { throw new UnsupportedOperationException("Unknown averaging approach: " + averaging); } }