MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / predict

Method predict

machine_learning/decision_tree.py:140–155  ·  view source on GitHub ↗

predict: @param x: a floating point value to predict the label of the prediction function works by recursively calling the predict function of the appropriate subtrees based on the tree's decision boundary

(self, x)

Source from the content-addressed store, hash-verified

138 return
139
140 def predict(self, x):
141 """
142 predict:
143 @param x: a floating point value to predict the label of
144 the prediction function works by recursively calling the predict function
145 of the appropriate subtrees based on the tree's decision boundary
146 """
147 if self.prediction is not None:
148 return self.prediction
149 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 else:
155 raise ValueError("Decision tree not yet trained")
156
157
158class TestDecisionTree:

Callers 7

mainFunction · 0.95
xgboostFunction · 0.45
sarimax_predictorFunction · 0.45
support_vector_regressorFunction · 0.45
lstm_prediction.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected