We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8edc478 commit c79034cCopy full SHA for c79034c
1 file changed
machine_learning/decision_tree.py
@@ -146,14 +146,13 @@ def predict(self, x):
146
"""
147
if self.prediction is not None:
148
return self.prediction
149
- elif self.left or self.right is not None:
+ elif self.left is not None and self.right is not None:
150
if x >= self.decision_boundary:
151
return self.right.predict(x)
152
else:
153
return self.left.predict(x)
154
155
- print("Error: Decision tree not yet trained")
156
- return None
+ raise ValueError("Decision tree not yet trained")
157
158
159
class TestDecisionTree:
@@ -201,4 +200,4 @@ def main():
201
200
main()
202
import doctest
203
204
- doctest.testmod(name="mean_squarred_error", verbose=True)
+ doctest.testmod(name="mean_squared_error", verbose=True)
0 commit comments