Finish all learners, but they don't pass tests. I have to figure out why they perform so bad.

This commit is contained in:
2020-09-24 17:32:29 -04:00
parent 51b2c9ceb0
commit 3f2d2f4df3
7 changed files with 511 additions and 15 deletions

View File

@@ -36,20 +36,13 @@ class DTLearner(object):
i_max = i
return i_max
def make_tree_absolute(self, tree):
for i in range(tree.shape[0]):
if tree[i, 2] == self.NA:
continue
tree[i, 2] = i + tree[i, 2]
tree[i, 3] = i + tree[i, 3]
return tree
def build_tree(self, xs, y):
assert(xs.shape[0] == y.shape[0])
assert(xs.shape[0] > 0) # If this is 0 something went wrong.
if xs.shape[0] == 1:
return self.create_node(self.LEAF, y[0], self.NA, self.NA)
if xs.shape[0] <= self.leaf_size:
value = np.median(y)
return self.create_node(self.LEAF, value, self.NA, self.NA)
if np.all(y[0] == y):
return self.create_node(self.LEAF, y[0], self.NA, self.NA)