File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
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 )
You can’t perform that action at this time.
0 commit comments