def test_projectionsToRulesTree_withDepth(self): projections = np.array([ [0, 0, 24, 0], [1, 70, 0, 31], [2, 20, 23, 0], [3, 30, 22, 0], [4, 40, 0, 34], [5, 50, 0, 32], [6, 60, 0, 33], [7, 10, 21, 0], ]) directions = [np.ones(3), np.ones(3)*2, np.ones(3)*3] quantiles = [0.5, 0.25, 0.75] maxLeafSize = 1 result = projectionsToRulesTree( projections, directions, quantiles, maxLeafSize, columnIndex = 1) expected = Node(Rule(np.ones(3), 30), Node(Rule(np.ones(3)*2, 21), np.array([7]), # <= 50 pctile on dim1, <= 25 pctile on dim2 np.array([0, 2, 3])), # <= 50 pctile on dim1, > 25 pctile on dim2 Node(Rule(np.ones(3)*3, 33), np.array([1, 5, 6]), # > 50 pctile on dim1, <= 75 pctile on dim3 np.array([4]))) # > 50 pctile on dim1, > 75 pctile on dim3 np.testing.assert_equal(expected, result)
def test_projectionsToRulesTree_simple(self): projections = np.array([ [0, 0], [1, 70], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 10], ]) directions = [np.ones(10)] quantiles = [0.5] maxLeafSize = 1 result = projectionsToRulesTree( projections, directions, quantiles, maxLeafSize, columnIndex = 1) expected = Node(Rule(np.ones(10), 30), np.array([0, 2, 3, 7]), np.array([1, 4, 5, 6])) np.testing.assert_equal(expected, result)