/** Calculate the F1-measure for a particular target index from an array list of classifications */ public double getF1 (int index) { double precision = getPrecision (index); double recall = getRecall (index); // gdruck@cs.umass.edu // When both precision and recall are 0, F1 is 0. if (precision==0.0 && recall==0.0) { return 0; } return 2*precision*recall/(precision+recall); }
public double getPrecision (Labeling label) { return getPrecision (label.getBestIndex()); }
/** Calculate the F1-measure for a particular target index from an array list of classifications */ public double getF1 (int index) { double precision = getPrecision (index); double recall = getRecall (index); // gdruck@cs.umass.edu // When both precision and recall are 0, F1 is 0. if (precision==0.0 && recall==0.0) { return 0; } return 2*precision*recall/(precision+recall); }
public double getPrecision (Labeling label) { return getPrecision (label.getBestIndex()); }
public double getPrecision (Labeling label) { return getPrecision (label.getBestIndex()); }
/** Calculate the F1-measure for a particular target index from an array list of classifications */ public double getF1 (int index) { double precision = getPrecision (index); double recall = getRecall (index); // gdruck@cs.umass.edu // When both precision and recall are 0, F1 is 0. if (precision==0.0 && recall==0.0) { return 0; } return 2*precision*recall/(precision+recall); }
public double getPrecision (InstanceList ilist, int index) { return new Trial(this, ilist).getPrecision(index); } public double getPrecision (InstanceList ilist, Labeling labeling) { return new Trial(this, ilist).getPrecision(labeling); }
public double getPrecision (InstanceList ilist, Object labelEntry) { return new Trial(this, ilist).getPrecision(labelEntry); } public double getRecall (InstanceList ilist, int index) { return new Trial(this, ilist).getRecall(index); }
public double getPrecision (InstanceList ilist, Labeling labeling) { return new Trial(this, ilist).getPrecision(labeling); } public double getPrecision (InstanceList ilist, Object labelEntry) { return new Trial(this, ilist).getPrecision(labelEntry); }
public double getPrecision (InstanceList ilist, Object labelEntry) { return new Trial(this, ilist).getPrecision(labelEntry); } public double getRecall (InstanceList ilist, int index) { return new Trial(this, ilist).getRecall(index); }
public double getPrecision (InstanceList ilist, int index) { return new Trial(this, ilist).getPrecision(index); } public double getPrecision (InstanceList ilist, Labeling labeling) { return new Trial(this, ilist).getPrecision(labeling); }
public double getPrecision (InstanceList ilist, Labeling labeling) { return new Trial(this, ilist).getPrecision(labeling); } public double getPrecision (InstanceList ilist, Object labelEntry) { return new Trial(this, ilist).getPrecision(labelEntry); }
public double getPrecision (InstanceList ilist, Labeling labeling) { return new Trial(this, ilist).getPrecision(labeling); } public double getPrecision (InstanceList ilist, Object labelEntry) { return new Trial(this, ilist).getPrecision(labelEntry); }
/** Calculate the precision of the classifier on an instance list for a particular target entry */ public double getPrecision (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getPrecision (index); }
private List<String> createRow( InstanceList training, InstanceList testing, String e, Classifier classifier, Trial trial) { List<String> row = new ArrayList<>(); row.add(e); row.add(Integer.toString(training.size())); row.add(Integer.toString(testing.size())); row.add(Double.toString(trial.getAccuracy())); for (String label : (String[]) classifier.getLabelAlphabet().toArray(new String[0])) { row.add(Double.toString(trial.getF1(label))); row.add(Double.toString(trial.getPrecision(label))); row.add(Double.toString(trial.getRecall(label))); } return row; }
/** Calculate the precision of the classifier on an instance list for a particular target entry */ public double getPrecision (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getPrecision (index); }
/** Calculate the precision of the classifier on an instance list for a particular target entry */ public double getPrecision (Object labelEntry) { int index; if (labelEntry instanceof Labeling) index = ((Labeling)labelEntry).getBestIndex(); else index = classifier.getLabelAlphabet().lookupIndex(labelEntry, false); if (index == -1) throw new IllegalArgumentException ("Label "+labelEntry.toString()+" is not a valid label."); return getPrecision (index); }
private List<String> createRow( InstanceList training, InstanceList testing, String e, Classifier classifier, Trial trial) { List<String> row = new ArrayList<>(); row.add(e); row.add(Integer.toString(training.size())); row.add(Integer.toString(testing.size())); row.add(Double.toString(trial.getAccuracy())); for (String label : (String[]) classifier.getLabelAlphabet().toArray(new String[0])) { row.add(Double.toString(trial.getF1(label))); row.add(Double.toString(trial.getPrecision(label))); row.add(Double.toString(trial.getRecall(label))); } return row; }
private void logAccuracyMetrics(Classifier classifier, Trial trial) { getMonitor().info("Accuracy: {}", trial.getAccuracy()); for (String label : (String[]) classifier.getLabelAlphabet().toArray(new String[0])) { getMonitor().info("F1 for class '{}': {}", label, trial.getF1(label)); getMonitor().info("Precision for class '{}' : {}", label, trial.getPrecision(label)); } }
private void logAccuracyMetrics(Classifier classifier, Trial trial) { getMonitor().info("Accuracy: {}", trial.getAccuracy()); for (String label : (String[]) classifier.getLabelAlphabet().toArray(new String[0])) { getMonitor().info("F1 for class '{}': {}", label, trial.getF1(label)); getMonitor().info("Precision for class '{}' : {}", label, trial.getPrecision(label)); } }