Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c79034c

Browse files
HarshPathak310MaximSmolskiy
andauthored
Update logical issue in decision_tree.py (TheAlgorithms#13303)
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
1 parent 8edc478 commit c79034c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎machine_learning/decision_tree.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,13 @@ def predict(self, x):
146146
"""
147147
if self.prediction is not None:
148148
return self.prediction
149-
elif self.left or self.right is not None:
149+
elif self.left isnotNoneand self.right is not None:
150150
if x >= self.decision_boundary:
151151
return self.right.predict(x)
152152
else:
153153
return self.left.predict(x)
154154
else:
155-
print("Error: Decision tree not yet trained")
156-
return None
155+
raise ValueError("Decision tree not yet trained")
157156

158157

159158
class TestDecisionTree:
@@ -201,4 +200,4 @@ def main():
201200
main()
202201
import doctest
203202

204-
doctest.testmod(name="mean_squarred_error", verbose=True)
203+
doctest.testmod(name="mean_squared_error", verbose=True)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /