Beispiel #1
0
 def test_findSplit_easy(self):
     data = load_testdata('fake_dataset_small.txt')
     split = DecisionTree.findSplit(None, data)
     self.assertEqual(split, (2, -15), "Should be (2,-15)")
     left, right = DecisionTree.partitionData(self, data, split)
     self.assertEqual(DecisionTree.findSplit(None, left), (None, None),
                      "Should be (None,None)")
     self.assertEqual(DecisionTree.findSplit(None, right), (4, -20),
                      "Should be (4,-20)")
Beispiel #2
0
    def test_partition_data(self):
        data = load_testdata('fake_dataset_small.txt')
        split = (2, -15)

        left, right = DecisionTree.partitionData(self, data, split)
        np.testing.assert_array_equal(left, data[data[:, split[0]] < split[1]],
                                      "Split arrays do not match")
        np.testing.assert_array_equal(right,
                                      data[data[:, split[0]] >= split[1]],
                                      "Split arrays do not match")