示例#1
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)
示例#2
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)
示例#3
0
 def test_split_chooser_exception_none_value(self):
     with self.assertRaises(ValueError):
         self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(),
                                         feature_selection=AllFeatureSelection(), split_chooser=None)
示例#4
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)
示例#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)
示例#6
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)
示例#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)
示例#8
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)
示例#9
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)
示例#10
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)
示例#11
0
 def setUp(self):
     self.tree_builder = TreeBuilder(split_criterion=GiniCriterion(),
                                     split_chooser=BestSplitChooser(),
                                     feature_selection=AllFeatureSelection())
示例#12
0
 def setUp(self):
     self.criterion = GiniCriterion()