Example #1
0
    def test_xft_classifiercv(self):
        cf_cv = ClassifierCv(self.labels, self.texts)
        name = 'ft'
        metric = 'f1'
        cf_cv.train_save_metrics(
            [('clf', FasttextClassifier(output=self.output, epoch=1))], metric,
            name, self.test_dir, self.test_dir)

        filename = os.path.join(self.test_dir, '_eval_report')
        cf_cv.calc_evaluation_report(self.df_test['text'],
                                     self.df_test['class'],
                                     savefile=filename)
        self.assertTrue(os.path.isfile(filename + "_" + name + ".csv"))
        self.assertTrue(os.path.isfile(filename + "_" + name + "_average.csv"))
Example #2
0
    def test_calc_evaluation_report(self):
        cf_cv = ClassifierCv(self.labels, self.texts)
        name = 'MultinomialNB'
        metric = 'f1'
        cf_cv.train_save_metrics([('vect', CountVectorizer()),
                                  ('tfidf', TfidfTransformer()),
                                  ('clf', MultinomialNB(alpha=.05))], metric,
                                 name, self.test_dir, self.test_dir)

        filename = os.path.join(self.test_dir, '_eval_report')
        cf_cv.calc_evaluation_report(self.df_test['text'],
                                     self.df_test['class'],
                                     savefile=filename)
        self.assertTrue(os.path.isfile(filename + "_" + name + ".csv"))
        self.assertTrue(os.path.isfile(filename + "_" + name + "_average.csv"))