Example #1
0
class AllFeatureSelectionTest(TestCase):
    def setUp(self):
        self.selection = AllFeatureSelection()

    def tearDown(self):
        pass

    def test_get_features(self):
        n_features = 5
        result = self.selection.get_features(5)
        expected = [x for x in range(n_features)]

        self.assertEqual(result, expected)
Example #2
0
 def test_split_criterion_exception_none_value(self):
     with self.assertRaises(ValueError):
         self.tree_builder = TreeBuilder(split_criterion=None, split_chooser=BestSplitChooser(),
                                         feature_selection=AllFeatureSelection())
Example #3
0
 def test_split_chooser_admissible_value(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection())
     self.assertIsInstance(self.tree_builder.split_chooser, BestSplitChooser)
Example #4
0
 def test_min_gain_split_non_negative_value(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection(), min_gain_split=1)
     self.assertEqual(self.tree_builder.min_gain_split, 1)
Example #5
0
 def test_min_gain_split_exception_negative_value(self):
     with self.assertRaises(ValueError):
         self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                         feature_selection=AllFeatureSelection(), min_gain_split=-1)
Example #6
0
 def test_min_samples_split_positive_value_greater_than_one(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection(), min_samples_split=2)
     self.assertEqual(self.tree_builder.min_samples_split, 2)
Example #7
0
 def test_min_samples_split_exception_less_than_two_instances(self):
     with self.assertRaises(ValueError):
         self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                         feature_selection=AllFeatureSelection(), min_samples_split=1)
Example #8
0
 def test_min_samples_leaf_positive_value(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection(), min_samples_leaf=1)
     self.assertEqual(self.tree_builder.min_samples_leaf, 1)
Example #9
0
 def test_min_samples_leaf_exception_none_value(self):
     with self.assertRaises(ValueError):
         self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                         feature_selection=AllFeatureSelection(), min_samples_leaf=None)
Example #10
0
 def test_max_depth_positive_value(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection(), max_depth=1)
     self.assertEqual(self.tree_builder.max_depth, 1)
Example #11
0
 def test_max_depth_none_value(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(), split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection(), max_depth=None)
     self.assertIsNone(self.tree_builder.max_depth)
Example #12
0
 def setUp(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(),
                                     split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection())
Example #13
0
 def setUp(self):
     self.selection = AllFeatureSelection()