diff --git a/machine_learning/decision_tree.py b/machine_learning/decision_tree.py index 7cd1b02c4181..8ec17d1cd4e4 100644 --- a/machine_learning/decision_tree.py +++ b/machine_learning/decision_tree.py @@ -49,6 +49,26 @@ def train(self, x, y): The contents of y are the labels for the corresponding X values train does not have a return value + + Examples: + 1. Try to train when x & y are of same length & 1 dimesions (No errors) + >>> dt = DecisionTree() + >>> dt.train(np.array([10,20,30,40,50]),np.array([0,0,0,1,1])) + + 2. Try to train when x is 2 dimesions + >>> dt = DecisionTree() + >>> dt.train(np.array([[1,2,3,4,5],[1,2,3,4,5]]),np.array([0,0,0,1,1])) + Error: Input data set must be one dimensional + + 3. Try to train when x and y are not of same length + >>> dt = DecisionTree() + >>> dt.train(np.array([1,2,3,4,5]),np.array([[0,0,0,1,1],[0,0,0,1,1]])) + Error: X and y have different lengths + + 4. Try to train when x & y are of same length but diffetent dimesions + >>> dt = DecisionTree() + >>> dt.train(np.array([1,2,3,4,5]),np.array([[1],[2],[3],[4],[5]])) + Error: Data set labels must be one dimensional """ """