Skip to content

Commit 12de830

Browse files
authored
Merge branch 'master' into vision-transformer-demo
2 parents 8701c92 + c79034c commit 12de830

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
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 is not None and 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)

maths/monte_carlo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from statistics import mean
99

1010

11-
def pi_estimator(iterations: int):
11+
def pi_estimator(iterations: int) -> None:
1212
"""
1313
An implementation of the Monte Carlo method used to find pi.
1414
1. Draw a 2x2 square centred at (0,0).

0 commit comments

Comments
 (0)