Search in sources :

Example 1 with PercentageBasedSplitter

use of de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter in project inception by inception-project.

the class OpenNlpNerRecommenderTest method thatEvaluationWorks.

@Test
public void thatEvaluationWorks() throws Exception {
    DataSplitter splitStrategy = new PercentageBasedSplitter(0.8, 10);
    OpenNlpNerRecommender sut = new OpenNlpNerRecommender(recommender, traits);
    List<CAS> casList = loadDevelopmentData();
    EvaluationResult result = sut.evaluate(casList, splitStrategy);
    double fscore = result.computeF1Score();
    double accuracy = result.computeAccuracyScore();
    double precision = result.computePrecisionScore();
    double recall = result.computeRecallScore();
    System.out.printf("F1-Score: %f%n", fscore);
    System.out.printf("Accuracy: %f%n", accuracy);
    System.out.printf("Precision: %f%n", precision);
    System.out.printf("Recall: %f%n", recall);
    assertThat(fscore).isStrictlyBetween(0.0, 1.0);
    assertThat(precision).isStrictlyBetween(0.0, 1.0);
    assertThat(recall).isStrictlyBetween(0.0, 1.0);
    assertThat(accuracy).isStrictlyBetween(0.0, 1.0);
}
Also used : DataSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter) PercentageBasedSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter) CAS(org.apache.uima.cas.CAS) EvaluationResult(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult) Test(org.junit.jupiter.api.Test)

Example 2 with PercentageBasedSplitter

use of de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter in project inception by inception-project.

the class OpenNlpPosRecommenderTest method thatEvaluationWorks.

@Test
public void thatEvaluationWorks() throws Exception {
    DataSplitter splitStrategy = new PercentageBasedSplitter(0.8, 10);
    OpenNlpPosRecommender sut = new OpenNlpPosRecommender(recommender, traits);
    List<CAS> casList = loadDevelopmentData();
    EvaluationResult result = sut.evaluate(casList, splitStrategy);
    double fscore = result.computeF1Score();
    double accuracy = result.computeAccuracyScore();
    double precision = result.computePrecisionScore();
    double recall = result.computeRecallScore();
    System.out.printf("F1-Score: %f%n", fscore);
    System.out.printf("Accuracy: %f%n", accuracy);
    System.out.printf("Precision: %f%n", precision);
    System.out.printf("Recall: %f%n", recall);
    assertThat(fscore).isStrictlyBetween(0.0, 1.0);
    assertThat(precision).isStrictlyBetween(0.0, 1.0);
    assertThat(recall).isStrictlyBetween(0.0, 1.0);
    assertThat(accuracy).isStrictlyBetween(0.0, 1.0);
}
Also used : DataSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter) PercentageBasedSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter) CAS(org.apache.uima.cas.CAS) EvaluationResult(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult) Test(org.junit.jupiter.api.Test)

Example 3 with PercentageBasedSplitter

use of de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter in project inception by inception-project.

the class DataMajorityNerRecommenderTest method thatEvaluationProducesSpecificResults.

@Test
public void thatEvaluationProducesSpecificResults() throws Exception {
    String text = "Angela Dorothea Merkel ist eine deutsche Politikerin (CDU) und seit dem 22. " + "November 2005 Bundeskanzlerin der Bundesrepublik Deutschland. " + "Merkel wuchs in der DDR auf und war dort als Physikerin am Zentralinstitut " + "für Physikalische Chemie wissenschaftlich tätig.";
    String[] vals = new String[] { "PER", "LOC", "LOC", "PER", "LOC", "ORG" };
    int[][] indices = new int[][] { { 0, 21 }, { 54, 56 }, { 110, 135 }, { 138, 143 }, { 158, 160 }, { 197, 236 } };
    List<CAS> testCas = getTestNECas(text, vals, indices);
    int expectedTestSize = 3;
    int expectedTrainSize = 3;
    EvaluationResult result = new DataMajorityNerRecommender(buildRecommender()).evaluate(testCas, new PercentageBasedSplitter(0.5, 500));
    assertThat(result.getTestSetSize()).as("correct test size").isEqualTo(expectedTestSize);
    assertThat(result.getTrainingSetSize()).as("correct training size").isEqualTo(expectedTrainSize);
    assertThat(result.computeAccuracyScore()).as("correct accuracy").isEqualTo(1.0 / 3);
    assertThat(result.computePrecisionScore()).as("correct precision").isEqualTo(1.0 / 9);
    assertThat(result.computeRecallScore()).as("correct recall").isEqualTo(1.0 / 3);
    assertThat(result.computeF1Score()).as("correct f1").isEqualTo((2.0 / 27) / (4.0 / 9));
}
Also used : PercentageBasedSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter) CAS(org.apache.uima.cas.CAS) EvaluationResult(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult) Test(org.junit.jupiter.api.Test)

Example 4 with PercentageBasedSplitter

use of de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter in project inception by inception-project.

the class DataMajorityNerRecommenderTest method thatEvaluationWithNoClassesWorks.

@Test
public void thatEvaluationWithNoClassesWorks() throws Exception {
    DataSplitter splitStrategy = new PercentageBasedSplitter(0.8, 10);
    DataMajorityNerRecommender sut = new DataMajorityNerRecommender(recommender);
    List<CAS> casList = new ArrayList<>();
    casList.add(getTestCasNoLabelLabels());
    double score = sut.evaluate(casList, splitStrategy).computeF1Score();
    System.out.printf("Score: %f%n", score);
    assertThat(score).isBetween(0.0, 1.0);
}
Also used : DataSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter) PercentageBasedSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter) CAS(org.apache.uima.cas.CAS) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 5 with PercentageBasedSplitter

use of de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter in project inception by inception-project.

the class DataMajorityNerRecommenderTest method thatEvaluationWorks.

@Test
public void thatEvaluationWorks() throws Exception {
    DataSplitter splitStrategy = new PercentageBasedSplitter(0.8, 10);
    DataMajorityNerRecommender sut = new DataMajorityNerRecommender(recommender);
    List<CAS> casList = loadDevelopmentData();
    EvaluationResult result = sut.evaluate(casList, splitStrategy);
    double fscore = result.computeF1Score();
    double accuracy = result.computeAccuracyScore();
    double precision = result.computePrecisionScore();
    double recall = result.computeRecallScore();
    System.out.printf("F1-Score: %f%n", fscore);
    System.out.printf("Accuracy: %f%n", accuracy);
    System.out.printf("Precision: %f%n", precision);
    System.out.printf("Recall: %f%n", recall);
    assertThat(fscore).isStrictlyBetween(0.0, 1.0);
    assertThat(precision).isStrictlyBetween(0.0, 1.0);
    assertThat(recall).isStrictlyBetween(0.0, 1.0);
    assertThat(accuracy).isStrictlyBetween(0.0, 1.0);
}
Also used : DataSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter) PercentageBasedSplitter(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter) CAS(org.apache.uima.cas.CAS) EvaluationResult(de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult) Test(org.junit.jupiter.api.Test)

Aggregations

PercentageBasedSplitter (de.tudarmstadt.ukp.inception.recommendation.api.evaluation.PercentageBasedSplitter)13 Test (org.junit.jupiter.api.Test)11 DataSplitter (de.tudarmstadt.ukp.inception.recommendation.api.evaluation.DataSplitter)10 EvaluationResult (de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult)10 CAS (org.apache.uima.cas.CAS)9 ArrayList (java.util.ArrayList)3 JCas (org.apache.uima.jcas.JCas)2 CasStorageSession (de.tudarmstadt.ukp.clarin.webanno.api.dao.casstorage.CasStorageSession)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)1 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)1 EvaluatedRecommender (de.tudarmstadt.ukp.inception.recommendation.api.model.EvaluatedRecommender)1 Recommender (de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender)1 RecommendationEngine (de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngine)1 RecommenderEvaluationResultEvent (de.tudarmstadt.ukp.inception.recommendation.event.RecommenderEvaluationResultEvent)1 SelectionTaskEvent (de.tudarmstadt.ukp.inception.recommendation.event.SelectionTaskEvent)1 List (java.util.List)1 NoResultException (javax.persistence.NoResultException)1 LazyInitializer (org.apache.commons.lang3.concurrent.LazyInitializer)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1