Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions machine_learning/decision_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

"""
Expand Down