Ejemplo n.º 1
0
    def test_reader__split_test_and_train_data_empty(self):
        """Check split_test_and_train_data method on the empty dataset"""

        reader = DSReader(dataset_empty_path)
        reader.make_dictionary()
        X, y = reader.vectorize()
        percent = 0.7
        with self.assertRaises(Exception):
            X_train, y_train, X_test, y_test = reader.split_train_and_test(
                X, y, percent)
Ejemplo n.º 2
0
    def test_reader__split_test_and_train_data_zero_size(self):
        """Check split_test_and_train_data method with argument size equals to zero"""

        reader = DSReader(dataset_split_path)
        reader.make_dictionary()
        X, y = reader.vectorize()
        percent = 0
        with self.assertRaises(Exception):
            X_train, y_train, X_test, y_test = reader.split_train_and_test(
                X, y, percent)
Ejemplo n.º 3
0
    def test_reader__split_test_and_train_data(self):
        """Check split_test_and_train_data method"""

        reader = DSReader(dataset_split_path)
        reader.make_dictionary()
        X, y = reader.vectorize()
        percent = 0.7
        X_train, y_train, X_test, y_test = reader.split_train_and_test(
            X, y, percent)
        self.assertEqual(X_train.shape[0], X.shape[0] * percent)
        self.assertEqual(X_test.shape[0], X.shape[0] * round(1 - percent, 2))
        self.assertEqual(y_train.shape[0], y.shape[0] * percent)
        self.assertEqual(y_test.shape[0], y.shape[0] * round(1 - percent, 2))