Exemple #1
0
 def test_predict_tails_with_novelties(self):
     """Test scoring tails with labeling as novel w.r.t. training and testing."""
     tails_df = get_tail_prediction_df(self.model, 'brazil', 'intergovorgs', testing=self.testing_mapped_triples)
     self.assertEqual(['tail_id', 'tail_label', 'score', 'in_training', 'in_testing'], list(tails_df.columns))
     self.assertEqual(self.model.num_entities, len(tails_df.index))
     training_tails = set(tails_df.loc[tails_df['in_training'], 'tail_label'])
     self.assertEqual({'usa', 'uk', 'netherlands', 'egypt', 'india', 'israel', 'indonesia'}, training_tails)
     testing_tails = set(tails_df.loc[tails_df['in_testing'], 'tail_label'])
     self.assertEqual({'poland', 'cuba'}, testing_tails)
Exemple #2
0
 def test_predict_tails_remove_known(self):
     """Test scoring tails while removing non-novel triples w.r.t. training and testing."""
     tails_df = get_tail_prediction_df(
         self.model,
         'brazil', 'intergovorgs', testing=self.testing_mapped_triples,
         remove_known=True,
     )
     self.assertEqual(['tail_id', 'tail_label', 'score'], list(tails_df.columns))
     self.assertEqual({'jordan', 'brazil', 'ussr', 'burma', 'china'}, set(tails_df['tail_label']))
Exemple #3
0
 def test_predict_tails_no_novelties(self):
     """Test scoring tails without labeling as novel w.r.t. training and testing."""
     tails_df = get_tail_prediction_df(
         self.model,
         'brazil', 'intergovorgs', testing=self.testing_mapped_triples,
         add_novelties=False,
     )
     self.assertEqual(['tail_id', 'tail_label', 'score'], list(tails_df.columns))
     self.assertEqual(len(self.model.triples_factory.entity_to_id), len(tails_df.index))
Exemple #4
0
 def test_predict_tails_remove_known(self):
     """Test scoring tails while removing non-novel triples w.r.t. training and testing."""
     tails_df = get_tail_prediction_df(
         self.model,
         "brazil",
         "intergovorgs",
         testing=self.testing_mapped_triples,
         remove_known=True,
         triples_factory=self.dataset.training,
     )
     self.assertEqual(["tail_id", "tail_label", "score"],
                      list(tails_df.columns))
     self.assertEqual({"jordan", "brazil", "ussr", "burma", "china"},
                      set(tails_df["tail_label"]))
Exemple #5
0
 def test_predict_tails_no_novelties(self):
     """Test scoring tails without labeling as novel w.r.t. training and testing."""
     tails_df = get_tail_prediction_df(
         self.model,
         "brazil",
         "intergovorgs",
         testing=self.testing_mapped_triples,
         triples_factory=self.dataset.training,
         add_novelties=False,
     )
     self.assertEqual(["tail_id", "tail_label", "score"],
                      list(tails_df.columns))
     self.assertEqual(len(self.dataset.training.entity_to_id),
                      len(tails_df.index))
Exemple #6
0
 def test_predict_tails_with_novelties(self):
     """Test scoring tails with labeling as novel w.r.t. training and testing."""
     tails_df = get_tail_prediction_df(
         self.model,
         "brazil",
         "intergovorgs",
         triples_factory=self.dataset.training,
         testing=self.testing_mapped_triples,
     )
     self.assertEqual(
         ["tail_id", "tail_label", "score", "in_training", "in_testing"],
         list(tails_df.columns))
     self.assertEqual(self.model.num_entities, len(tails_df.index))
     training_tails = set(tails_df.loc[tails_df["in_training"],
                                       "tail_label"])
     self.assertEqual(
         {
             "usa", "uk", "netherlands", "egypt", "india", "israel",
             "indonesia"
         }, training_tails)
     testing_tails = set(tails_df.loc[tails_df["in_testing"], "tail_label"])
     self.assertEqual({"poland", "cuba"}, testing_tails)