MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / DecisionTree

Class DecisionTree

supervised_class/dt.py:167–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166# This class is kind of redundant
167class DecisionTree:
168 def __init__(self, max_depth=None):
169 self.max_depth = max_depth
170
171 def fit(self, X, Y):
172 self.root = TreeNode(max_depth=self.max_depth)
173 self.root.fit(X, Y)
174
175 def predict(self, X):
176 return self.root.predict(X)
177
178 def score(self, X, Y):
179 P = self.predict(X)
180 return np.mean(P == Y)
181
182
183if __name__ == '__main__':

Callers 1

dt.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected