コード例 #1
0
ファイル: test_case.py プロジェクト: frosky/Text_Classifier
class ModelTest(TestBodyModel):
    @classmethod
    def setUpClass(cls):
        print "#################### Begin Testing Model Class ####################" + "\n"

    @classmethod
    def tearDownClass(cls):
        print "\n" + "###################### End Testing Model Class ######################"

    def setUp(self):
        test_name = self.shortDescription()
        super(ModelTest, self).setUp()
        self.mock_obj = Model(self.test_data)

        if test_name == "Test routine fill_feature_target() in Model":
            self.term_freq = res.term_frequency
            print "setting up for testing fill_feature_target()"

        elif test_name == "Test routine evaluate_cross_validation() in Model":
            self.mock_obj.set_classifier("svm_linear")
            self.accuracy = res.accuracy_svm_bag_of_words
            self.accuracy_mean = res.accuracy_svm_bag_of_words_mean
            print "setting up for testing evaluate_cross_validation()"

    def tearDown(self):
        test_name = self.shortDescription()
        self.korpus_file = None
        self.anno_file = None
        self.test_korpus = None
        self.test_data = None
        self.mock_obj = None

        if test_name == "Test routine fill_feature_target() in Model":
            print "cleaning up for testing fill_feature_target()"
            self.term_freq = None
            print "--------------------------------------------------------------"

        elif test_name == "Test routine evaluate_cross_validation() in Model":
            self.accuracy = None
            self.accuracy_mean = None

            print "cleaning up for testing evaluate_cross_validation()"
            print "--------------------------------------------------------------"

    def test__model__fill_feature_target(self):
        """ Test routine fill_feature_target() in Model """
        for index in range(len(self.test_data.real_data.values())):
            reference = np.array(self.test_data.real_data.values()[index])
            (self.mock_obj.feature_samples[index] == reference).all()

    def test__model__evaluate_cross_validation(self):
        """ Test routine evaluate_cross_validation() in Model """
        acc_list, acc_mean = self.mock_obj.evaluate_cross_validation(10)
        self.assertListEqual(self.accuracy, acc_list)
        self.assertEqual(self.accuracy_mean, acc_mean)
コード例 #2
0
ファイル: test_case.py プロジェクト: frosk1/Text_Classifier
class ModelTest(TestBodyModel):
    @classmethod
    def setUpClass(cls):
        print "#################### Begin Testing Model Class ####################" + "\n"

    @classmethod
    def tearDownClass(cls):
        print "\n" + "###################### End Testing Model Class ######################"

    def setUp(self):
        test_name = self.shortDescription()
        super(ModelTest, self).setUp()
        self.mock_obj = Model(self.test_data)

        if test_name == "Test routine fill_feature_target() in Model":
            self.term_freq = res.term_frequency
            print "setting up for testing fill_feature_target()"

        elif test_name == "Test routine evaluate_cross_validation() in Model":
            self.mock_obj.set_classifier("svm_linear")
            self.accuracy = res.accuracy_svm_bag_of_words
            self.accuracy_mean = res.accuracy_svm_bag_of_words_mean
            print "setting up for testing evaluate_cross_validation()"

    def tearDown(self):
        test_name = self.shortDescription()
        self.korpus_file = None
        self.anno_file = None
        self.test_korpus = None
        self.test_data = None
        self.mock_obj = None

        if test_name == "Test routine fill_feature_target() in Model":
            print "cleaning up for testing fill_feature_target()"
            self.term_freq = None
            print "--------------------------------------------------------------"

        elif test_name == "Test routine evaluate_cross_validation() in Model":
            self.accuracy = None
            self.accuracy_mean = None

            print "cleaning up for testing evaluate_cross_validation()"
            print "--------------------------------------------------------------"

    def test__model__fill_feature_target(self):
        """ Test routine fill_feature_target() in Model """
        for index in range(len(self.test_data.real_data.values())):
            reference = np.array(self.test_data.real_data.values()[index])
            (self.mock_obj.feature_samples[index] == reference).all()

    def test__model__evaluate_cross_validation(self):
        """ Test routine evaluate_cross_validation() in Model """
        acc_list, acc_mean = self.mock_obj.evaluate_cross_validation(10)
        self.assertListEqual(self.accuracy, acc_list)
        self.assertEqual(self.accuracy_mean, acc_mean)
コード例 #3
0
ファイル: test_case.py プロジェクト: frosk1/Text_Classifier
    def setUp(self):
        test_name = self.shortDescription()
        super(ModelTest, self).setUp()
        self.mock_obj = Model(self.test_data)

        if test_name == "Test routine fill_feature_target() in Model":
            self.term_freq = res.term_frequency
            print "setting up for testing fill_feature_target()"

        elif test_name == "Test routine evaluate_cross_validation() in Model":
            self.mock_obj.set_classifier("svm_linear")
            self.accuracy = res.accuracy_svm_bag_of_words
            self.accuracy_mean = res.accuracy_svm_bag_of_words_mean
            print "setting up for testing evaluate_cross_validation()"
コード例 #4
0
ファイル: test_case.py プロジェクト: frosky/Text_Classifier
    def setUp(self):
        test_name = self.shortDescription()
        super(ModelTest, self).setUp()
        self.mock_obj = Model(self.test_data)

        if test_name == "Test routine fill_feature_target() in Model":
            self.term_freq = res.term_frequency
            print "setting up for testing fill_feature_target()"

        elif test_name == "Test routine evaluate_cross_validation() in Model":
            self.mock_obj.set_classifier("svm_linear")
            self.accuracy = res.accuracy_svm_bag_of_words
            self.accuracy_mean = res.accuracy_svm_bag_of_words_mean
            print "setting up for testing evaluate_cross_validation()"