Esempio n. 1
0
    def acc_per_tag(self, y_hat, y):
        assert isinstance(y_hat, pd.Series)
        assert isinstance(y, pd.Series)

        roll_y = pd.Series(y.values.reshape(-1)).drop(
            ['<PAD>', '*', '<STOP>', ','])
        roll_y_hat = pd.Series(y_hat.values.reshape(-1)).drop(
            ['<PAD>', '*', '<STOP>', ','])

        most_reacuent_tags = self.tag_corpus[:10]
        sc = Score(most_reacuent_tags)
        sc.fit(roll_y, roll_y_hat)
        return sc.acc_per_tag(roll_y, roll_y_hat)
Esempio n. 2
0
 def test_all_data(self):
     data = PreprocessTags().load_data(r'..\data\test.wtag')
     y_hat = data.y
     y = data.y
     roll_y = pd.Series(y.values.reshape(-1))
     roll_y_hat = pd.Series(y_hat.values.reshape(-1))
     index = pd.value_counts(y.values.reshape(-1)).index
     most_reacuent_tags = pd.Series(index,
                                    index=index).drop(['<STOP>', '*'])[:10]
     sc = Score(most_reacuent_tags)
     sc.fit(roll_y, roll_y_hat)
     cm = sc.matrix_confusion()
     acc_dict = sc.acc_per_tag(y, y_hat)
     print(acc_dict)
     print(cm)