This example uses the "iris" data set (iris_input). The data has values for four attributes (sepal_length, sepal_width, petal_length and petal_width), which are grouped into three categories (setosa (1), versicolor (2), virginica (3)). From the raw data, the example creates a train and test set.
The function Single_Tree_Drive acts on the train set to generate the model. The Single_Tree_Predict function uses that model and a test set to predict the output. The prediction accuracy is determined based on the original and prediction results.
id | sepal_length | sepal_width | petal_length | petal_width | species |
---|---|---|---|---|---|
1 | 5.1 | 3.5 | 1.4 | 0.2 | 1 |
2 | 4.9 | 3 | 1.4 | 0.2 | 1 |
3 | 4.7 | 3.2 | 1.3 | 0.2 | 1 |
4 | 4.6 | 3.1 | 1.5 | 0.2 | 1 |
5 | 5 | 3.6 | 1.4 | 0.2 | 1 |
6 | 5.4 | 3.9 | 1.7 | 0.4 | 1 |
7 | 4.6 | 3.4 | 1.4 | 0.3 | 1 |
8 | 5 | 3.4 | 1.5 | 0.2 | 1 |
9 | 4.4 | 2.9 | 1.4 | 0.2 | 1 |
10 | 4.9 | 3.1 | 1.5 | 0.1 | 1 |
... | ... | ... | ... | ... | ... |