File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff 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
159158class 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 )
Original file line number Diff line number Diff line change 88from 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).
You can’t perform that action at this time.
0 commit comments