I am writing a decision tree trained with the ID3 algorithm from scratch. I wanted to be able to train on and classify continuous data, so I implemented k-means clustering and reduced the range of values of any input training or predicting data.
However, I ran into the problem where an attribute value that was not encountered during training, in a deep node somewhere in the tree, but that exists further up was encountered. All data points with this specific attribute value probably ended up on a different branch of the tree.
So to 'solve' this, whenever an unknown attribute value is encountered for a node, I sent it down a random existing branch.
I get 95.45% accuracy using randomly split 85%-15% training-test data with iris.
Is this an acceptable approach to take or have I gotten something wrong here?
Here's the code: https://github.com/jamalmoir/ml_components/blob/master/ml_components/models/decision_tree.py
Thanks