public boolean evaluate (ACRF acrf, int iter, InstanceList training, InstanceList validation, InstanceList testing) { // Don't evaluate if it is too early in training to matter if (!shouldDoEvaluate (iter)) return true; InstanceList[] lists = new InstanceList[] {training, validation, testing}; String[] listnames = new String[] {"Training", "Validation", "Testing"}; for (int k = 0; k < lists.length; k++) if (lists[k] != null) { test (acrf, lists[k], listnames[k]); } return true; }
private Sequence processTrueOutput (Sequence sequence) { if (sequence instanceof LabelsSequence) { LabelsSequence lseq = (LabelsSequence) sequence; return slice (lseq, slice); } else { return sequence; } }
public void test(InstanceList gold, List returned, String description) { TestResults results = new TestResults (segmentStartTags, segmentContinueTags); for (int i = 0; i < gold.size(); i++) { Instance instance = gold.get(i); Sequence trueOutput = processTrueOutput ((Sequence) instance.getTarget()); Sequence predOutput = slice ((LabelsSequence) returned.get (i), slice); assert (predOutput.size() == trueOutput.size()); results.incrementCounts (trueOutput, predOutput); } results.logResults (description); }
private static ACRFEvaluator createEvaluator (LinkedList toks) { String type = (String) toks.removeFirst (); if (type.equalsIgnoreCase ("SEGMENT")) { int slice = Integer.parseInt ((String) toks.removeFirst ()); if (toks.size() % 2 != 0) throw new RuntimeException ("Error in --eval "+evalOption.value+": Every start tag must have a continue."); int numTags = toks.size () / 2; String[] startTags = new String [numTags]; String[] continueTags = new String [numTags]; for (int i = 0; i < numTags; i++) { startTags[i] = (String) toks.removeFirst (); continueTags[i] = (String) toks.removeFirst (); } return new MultiSegmentationEvaluatorACRF (startTags, continueTags, slice); } else if (type.equalsIgnoreCase ("LOG")) { return new DefaultAcrfTrainer.LogEvaluator (); } else if (type.equalsIgnoreCase ("SERIAL")) { List evals = new ArrayList (); while (!toks.isEmpty ()) { evals.add (createEvaluator (toks)); } return new AcrfSerialEvaluator (evals); } else { throw new RuntimeException ("Error in --eval "+evalOption.value+": illegal evaluator "+type); } }
public void test(InstanceList gold, List returned, String description) { TestResults results = new TestResults (segmentStartTags, segmentContinueTags); for (int i = 0; i < gold.size(); i++) { Instance instance = gold.get(i); Sequence trueOutput = processTrueOutput ((Sequence) instance.getTarget()); Sequence predOutput = slice ((LabelsSequence) returned.get (i), slice); assert (predOutput.size() == trueOutput.size()); results.incrementCounts (trueOutput, predOutput); } results.logResults (description); }
private static ACRFEvaluator createEvaluator (LinkedList toks) { String type = (String) toks.removeFirst (); if (type.equalsIgnoreCase ("SEGMENT")) { int slice = Integer.parseInt ((String) toks.removeFirst ()); if (toks.size() % 2 != 0) throw new RuntimeException ("Error in --eval "+evalOption.value+": Every start tag must have a continue."); int numTags = toks.size () / 2; String[] startTags = new String [numTags]; String[] continueTags = new String [numTags]; for (int i = 0; i < numTags; i++) { startTags[i] = (String) toks.removeFirst (); continueTags[i] = (String) toks.removeFirst (); } return new MultiSegmentationEvaluatorACRF (startTags, continueTags, slice); } else if (type.equalsIgnoreCase ("LOG")) { return new DefaultAcrfTrainer.LogEvaluator (); } else if (type.equalsIgnoreCase ("SERIAL")) { List evals = new ArrayList (); while (!toks.isEmpty ()) { evals.add (createEvaluator (toks)); } return new AcrfSerialEvaluator (evals); } else { throw new RuntimeException ("Error in --eval "+evalOption.value+": illegal evaluator "+type); } }
public void test(InstanceList gold, List returned, String description) { TestResults results = new TestResults (segmentStartTags, segmentContinueTags); for (int i = 0; i < gold.size(); i++) { Instance instance = gold.get(i); Sequence trueOutput = processTrueOutput ((Sequence) instance.getTarget()); Sequence predOutput = slice ((LabelsSequence) returned.get (i), slice); assert (predOutput.size() == trueOutput.size()); results.incrementCounts (trueOutput, predOutput); } results.logResults (description); }
public boolean evaluate (ACRF acrf, int iter, InstanceList training, InstanceList validation, InstanceList testing) { // Don't evaluate if it is too early in training to matter if (!shouldDoEvaluate (iter)) return true; InstanceList[] lists = new InstanceList[] {training, validation, testing}; String[] listnames = new String[] {"Training", "Validation", "Testing"}; for (int k = 0; k < lists.length; k++) if (lists[k] != null) { test (acrf, lists[k], listnames[k]); } return true; }
private static ACRFEvaluator createEvaluator (LinkedList toks) { String type = (String) toks.removeFirst (); if (type.equalsIgnoreCase ("SEGMENT")) { int slice = Integer.parseInt ((String) toks.removeFirst ()); if (toks.size() % 2 != 0) throw new RuntimeException ("Error in --eval "+evalOption.value+": Every start tag must have a continue."); int numTags = toks.size () / 2; String[] startTags = new String [numTags]; String[] continueTags = new String [numTags]; for (int i = 0; i < numTags; i++) { startTags[i] = (String) toks.removeFirst (); continueTags[i] = (String) toks.removeFirst (); } return new MultiSegmentationEvaluatorACRF (startTags, continueTags, slice); } else if (type.equalsIgnoreCase ("LOG")) { return new DefaultAcrfTrainer.LogEvaluator (); } else if (type.equalsIgnoreCase ("SERIAL")) { List evals = new ArrayList (); while (!toks.isEmpty ()) { evals.add (createEvaluator (toks)); } return new AcrfSerialEvaluator (evals); } else { throw new RuntimeException ("Error in --eval "+evalOption.value+": illegal evaluator "+type); } }
private Sequence processTrueOutput (Sequence sequence) { if (sequence instanceof LabelsSequence) { LabelsSequence lseq = (LabelsSequence) sequence; return slice (lseq, slice); } else { return sequence; } }
public boolean evaluate (ACRF acrf, int iter, InstanceList training, InstanceList validation, InstanceList testing) { // Don't evaluate if it is too early in training to matter if (!shouldDoEvaluate (iter)) return true; InstanceList[] lists = new InstanceList[] {training, validation, testing}; String[] listnames = new String[] {"Training", "Validation", "Testing"}; for (int k = 0; k < lists.length; k++) if (lists[k] != null) { test (acrf, lists[k], listnames[k]); } return true; }
private static ACRFEvaluator createEvaluator (LinkedList toks) { String type = (String) toks.removeFirst (); if (type.equalsIgnoreCase ("SEGMENT")) { int slice = Integer.parseInt ((String) toks.removeFirst ()); if (toks.size() % 2 != 0) throw new RuntimeException ("Error in --eval "+evalOption.value+": Every start tag must have a continue."); int numTags = toks.size () / 2; String[] startTags = new String [numTags]; String[] continueTags = new String [numTags]; for (int i = 0; i < numTags; i++) { startTags[i] = (String) toks.removeFirst (); continueTags[i] = (String) toks.removeFirst (); } return new MultiSegmentationEvaluatorACRF (startTags, continueTags, slice); } else if (type.equalsIgnoreCase ("LOG")) { return new DefaultAcrfTrainer.LogEvaluator (); } else if (type.equalsIgnoreCase ("SERIAL")) { List evals = new ArrayList (); while (!toks.isEmpty ()) { evals.add (createEvaluator (toks)); } return new AcrfSerialEvaluator (evals); } else { throw new RuntimeException ("Error in --eval "+evalOption.value+": illegal evaluator "+type); } }
private Sequence processTrueOutput (Sequence sequence) { if (sequence instanceof LabelsSequence) { LabelsSequence lseq = (LabelsSequence) sequence; return slice (lseq, slice); } else { return sequence; } }
private static ACRFEvaluator createEvaluator (LinkedList toks) { String type = (String) toks.removeFirst (); if (type.equalsIgnoreCase ("SEGMENT")) { int slice = Integer.parseInt ((String) toks.removeFirst ()); if (toks.size() % 2 != 0) throw new RuntimeException ("Error in --eval "+evalOption.value+": Every start tag must have a continue."); int numTags = toks.size () / 2; String[] startTags = new String [numTags]; String[] continueTags = new String [numTags]; for (int i = 0; i < numTags; i++) { startTags[i] = (String) toks.removeFirst (); continueTags[i] = (String) toks.removeFirst (); } return new MultiSegmentationEvaluatorACRF (startTags, continueTags, slice); } else if (type.equalsIgnoreCase ("LOG")) { return new DefaultAcrfTrainer.LogEvaluator (); } else if (type.equalsIgnoreCase ("SERIAL")) { List evals = new ArrayList (); while (!toks.isEmpty ()) { evals.add (createEvaluator (toks)); } return new AcrfSerialEvaluator (evals); } else { throw new RuntimeException ("Error in --eval "+evalOption.value+": illegal evaluator "+type); } }
private static ACRFEvaluator createEvaluator (LinkedList toks) { String type = (String) toks.removeFirst (); if (type.equalsIgnoreCase ("SEGMENT")) { int slice = Integer.parseInt ((String) toks.removeFirst ()); if (toks.size() % 2 != 0) throw new RuntimeException ("Error in --eval "+evalOption.value+": Every start tag must have a continue."); int numTags = toks.size () / 2; String[] startTags = new String [numTags]; String[] continueTags = new String [numTags]; for (int i = 0; i < numTags; i++) { startTags[i] = (String) toks.removeFirst (); continueTags[i] = (String) toks.removeFirst (); } return new MultiSegmentationEvaluatorACRF (startTags, continueTags, slice); } else if (type.equalsIgnoreCase ("LOG")) { return new DefaultAcrfTrainer.LogEvaluator (); } else if (type.equalsIgnoreCase ("SERIAL")) { List evals = new ArrayList (); while (!toks.isEmpty ()) { evals.add (createEvaluator (toks)); } return new AcrfSerialEvaluator (evals); } else { throw new RuntimeException ("Error in --eval "+evalOption.value+": illegal evaluator "+type); } }