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);
}
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);
}
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));
}
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);
}
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);
}
Aggregations