MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / predict

Method predict

machine_learning/decision_tree.py:100–116  ·  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

98 return
99
100 def predict(self, x):
101 """
102 predict:
103 @param x: a floating point value to predict the label of
104 the prediction function works by recursively calling the predict function
105 of the appropriate subtrees based on the tree's decision boundary
106 """
107 if self.prediction is not None:
108 return self.prediction
109 elif self.left or self.right is not None:
110 if x >= self.decision_boundary:
111 return self.right.predict(x)
112 else:
113 return self.left.predict(x)
114 else:
115 print("Error: Decision tree not yet trained")
116 return None
117
118def main():
119 """

Callers 3

mainFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected