public double getAccuracy(String label) { int labelId = labelMap.get(label); int labelTotal = 0; int correct = 0; for (int i = 0; i < numLabels(); i++) { labelTotal += confusionMatrix[labelId][i]; if (i == labelId) { correct += confusionMatrix[labelId][i]; } } return 100.0 * correct / labelTotal; }
public double getAccuracy(String label) { int labelId = labelMap.get(label); int labelTotal = 0; int correct = 0; for (int i = 0; i < numLabels(); i++) { labelTotal += confusionMatrix[labelId][i]; if (i == labelId) { correct += confusionMatrix[labelId][i]; } } return 100.0 * correct / labelTotal; }
/** Sum of true positives and false negatives */ private int getActualNumberOfTestExamplesForClass(String label) { int labelId = labelMap.get(label); int sum = 0; for (int i = 0; i < numLabels(); i++) { sum += confusionMatrix[labelId][i]; } return sum; }
/** Sum of true positives and false negatives */ private int getActualNumberOfTestExamplesForClass(String label) { int labelId = labelMap.get(label); int sum = 0; for (int i = 0; i < numLabels(); i++) { sum += confusionMatrix[labelId][i]; } return sum; }
public double getPrecision(String label) { int labelId = labelMap.get(label); int truePositives = confusionMatrix[labelId][labelId]; int falsePositives = 0; for (int i = 0; i < numLabels(); i++) { if (i == labelId) { continue; } falsePositives += confusionMatrix[i][labelId]; } if (truePositives + falsePositives == 0) { return 0; } return ((double) truePositives) / (truePositives + falsePositives); }
public double getPrecision(String label) { int labelId = labelMap.get(label); int truePositives = confusionMatrix[labelId][labelId]; int falsePositives = 0; for (int i = 0; i < numLabels(); i++) { if (i == labelId) { continue; } falsePositives += confusionMatrix[i][labelId]; } if (truePositives + falsePositives == 0) { return 0; } return ((double) truePositives) / (truePositives + falsePositives); }
public double getRecall(String label) { int labelId = labelMap.get(label); int truePositives = confusionMatrix[labelId][labelId]; int falseNegatives = 0; for (int i = 0; i < numLabels(); i++) { if (i == labelId) { continue; } falseNegatives += confusionMatrix[labelId][i]; } if (truePositives + falseNegatives == 0) { return 0; } return ((double) truePositives) / (truePositives + falseNegatives); }
public double getRecall(String label) { int labelId = labelMap.get(label); int truePositives = confusionMatrix[labelId][labelId]; int falseNegatives = 0; for (int i = 0; i < numLabels(); i++) { if (i == labelId) { continue; } falseNegatives += confusionMatrix[labelId][i]; } if (truePositives + falseNegatives == 0) { return 0; } return ((double) truePositives) / (truePositives + falseNegatives); }
public double getWeightedF1score() { double[] f1Scores = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { f1Scores[index] = getF1score(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(f1Scores, weights); }
public double getWeightedF1score() { double[] f1Scores = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { f1Scores[index] = getF1score(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(f1Scores, weights); }
public double getWeightedRecall() { double[] recalls = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { recalls[index] = getRecall(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(recalls, weights); }
public double getWeightedRecall() { double[] recalls = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { recalls[index] = getRecall(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(recalls, weights); }
public double getWeightedPrecision() { double[] precisions = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { precisions[index] = getPrecision(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(precisions, weights); }
public double getWeightedPrecision() { double[] precisions = new double[numLabels()]; double[] weights = new double[numLabels()]; int index = 0; for (String label : labelMap.keySet()) { precisions[index] = getPrecision(label); weights[index] = getActualNumberOfTestExamplesForClass(label); index++; } return new Mean().evaluate(precisions, weights); }