Search in sources :

Example 1 with ClassificationTester

use of edu.illinois.cs.cogcomp.core.experiments.ClassificationTester in project cogcomp-nlp by CogComp.

the class ConstituentSpanSplittingEvaluatorTest method setUp.

@Before
public void setUp() throws Exception {
    splittingTester = new ClassificationTester();
    TextAnnotation prediction1TA = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(new String[] {}, false, 1);
    TextAnnotation prediction2TA = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(new String[] {}, false, 2);
    prediction1 = (SpanLabelView) prediction1TA.getView(ViewNames.TOKENS);
    prediction2 = (SpanLabelView) prediction2TA.getView(ViewNames.TOKENS);
}
Also used : ClassificationTester(edu.illinois.cs.cogcomp.core.experiments.ClassificationTester) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Before(org.junit.Before)

Example 2 with ClassificationTester

use of edu.illinois.cs.cogcomp.core.experiments.ClassificationTester in project cogcomp-nlp by CogComp.

the class CorefEvaluatorTest method testScores.

@Test
public void testScores() throws Exception {
    ClassificationTester mucTester = new ClassificationTester();
    CorefMUCEvaluator mucEvaluator = new CorefMUCEvaluator();
    mucEvaluator.evaluate(mucTester, gold, predicted);
    assertEquals(mucTester.getMacroF1(), 0.94, 0.01);
    assertEquals(mucTester.getMacroPrecision(), 0.9, 0.01);
    assertEquals(mucTester.getMacroRecall(), 1.0, 0.01);
    ClassificationTester bcubedTester = new ClassificationTester();
    CorefBCubedEvaluator bcubedEvaluator = new CorefBCubedEvaluator();
    bcubedEvaluator.evaluate(bcubedTester, gold, predicted);
    assertEquals(bcubedTester.getMacroF1(), 0.73, 0.01);
    assertEquals(bcubedTester.getMacroPrecision(), 0.58, 0.01);
    assertEquals(bcubedTester.getMacroRecall(), 1.0, 0.01);
    ClassificationTester accuracyTester = new ClassificationTester();
    CorefAccuracyEvaluator accuracyEvaluator = new CorefAccuracyEvaluator();
    accuracyEvaluator.evaluate(accuracyTester, gold, predicted);
    assertEquals(accuracyTester.getMacroF1(), 0.68, 0.01);
    assertEquals(accuracyTester.getMacroPrecision(), 0.51, 0.01);
    assertEquals(accuracyTester.getMacroRecall(), 1.0, 0.01);
}
Also used : ClassificationTester(edu.illinois.cs.cogcomp.core.experiments.ClassificationTester) Test(org.junit.Test)

Example 3 with ClassificationTester

use of edu.illinois.cs.cogcomp.core.experiments.ClassificationTester in project cogcomp-nlp by CogComp.

the class PredicateArgumentEvaluatorTest method setUp.

@Before
public void setUp() throws Exception {
    senseTester = new ClassificationTester();
    argLabelTester = new ClassificationTester();
    String[] viewsToAdd = { ViewNames.SRL_VERB };
    TextAnnotation taGold = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, false, 3);
    TextAnnotation taPred = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, false, 3);
    gold = (PredicateArgumentView) taGold.getView(ViewNames.SRL_VERB);
    predicted = (PredicateArgumentView) taPred.getView(ViewNames.SRL_VERB);
}
Also used : ClassificationTester(edu.illinois.cs.cogcomp.core.experiments.ClassificationTester) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Before(org.junit.Before)

Example 4 with ClassificationTester

use of edu.illinois.cs.cogcomp.core.experiments.ClassificationTester in project cogcomp-nlp by CogComp.

the class ConstituentLabelingEvaluatorTest method setUp.

@Before
public void setUp() throws Exception {
    splittingTester = new ClassificationTester();
    String[] viewsToAdd = { ViewNames.POS };
    TextAnnotation goldTA = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, false, 3);
    TextAnnotation predictionTA = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, true, 3);
    gold = (SpanLabelView) goldTA.getView(ViewNames.POS);
    predicted = (SpanLabelView) predictionTA.getView(ViewNames.POS);
}
Also used : ClassificationTester(edu.illinois.cs.cogcomp.core.experiments.ClassificationTester) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Before(org.junit.Before)

Example 5 with ClassificationTester

use of edu.illinois.cs.cogcomp.core.experiments.ClassificationTester in project cogcomp-nlp by CogComp.

the class VerbSenseClassifierMain method evaluate.

@CommandDescription(description = "Performs evaluation.", usage = "evaluate")
public static void evaluate() throws Exception {
    SenseManager manager = getManager(false);
    Dataset testSet = Dataset.PTBTest;
    ILPSolverFactory solver = new ILPSolverFactory(ILPSolverFactory.SolverType.JLISCuttingPlaneGurobi);
    ClassificationTester senseTester = new ClassificationTester();
    long start = System.currentTimeMillis();
    int count = 0;
    manager.getModelInfo().loadWeightVector();
    IResetableIterator<TextAnnotation> dataset = SentenceDBHandler.instance.getDataset(testSet);
    while (dataset.hasNext()) {
        TextAnnotation ta = dataset.next();
        if (!ta.hasView(SenseManager.getGoldViewName()))
            continue;
        TokenLabelView gold = (TokenLabelView) ta.getView(SenseManager.getGoldViewName());
        ILPInference inference = manager.getInference(solver, gold.getConstituents());
        assert inference != null;
        TokenLabelView prediction = inference.getOutputView();
        evaluateSense(gold, prediction, senseTester);
        count++;
        if (count % 1000 == 0) {
            long end = System.currentTimeMillis();
            log.info(count + " sentences done. Took " + (end - start) + "ms, Micro-F1 so far = " + senseTester.getMicroF1());
        }
    }
    long end = System.currentTimeMillis();
    System.out.println(count + " sentences done. Took " + (end - start) + "ms");
    System.out.println("\n\n* Sense");
    System.out.println(senseTester.getPerformanceTable(false).toOrgTable());
}
Also used : ILPSolverFactory(edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory) Dataset(edu.illinois.cs.cogcomp.verbsense.data.Dataset) ClassificationTester(edu.illinois.cs.cogcomp.core.experiments.ClassificationTester) SenseManager(edu.illinois.cs.cogcomp.verbsense.core.SenseManager) TokenLabelView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) ILPInference(edu.illinois.cs.cogcomp.verbsense.inference.ILPInference) CommandDescription(edu.illinois.cs.cogcomp.core.utilities.commands.CommandDescription)

Aggregations

ClassificationTester (edu.illinois.cs.cogcomp.core.experiments.ClassificationTester)5 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)4 Before (org.junit.Before)3 TokenLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView)1 CommandDescription (edu.illinois.cs.cogcomp.core.utilities.commands.CommandDescription)1 ILPSolverFactory (edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory)1 SenseManager (edu.illinois.cs.cogcomp.verbsense.core.SenseManager)1 Dataset (edu.illinois.cs.cogcomp.verbsense.data.Dataset)1 ILPInference (edu.illinois.cs.cogcomp.verbsense.inference.ILPInference)1 Test (org.junit.Test)1