[
https://issues.apache.org/jira/browse/MAHOUT-926?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ikumasa Mukai updated MAHOUT-926:
---------------------------------
Attachment: MAHOUT-926.patch
I made a patch which can be used on your code like this.
Sorry for late to attach.
To dump tree:
{code}
DecisionTreeBuilder builder = new DecisionTreeBuilder();
Node tree = builder.build(RandomUtils.getRandom(), data);
TreeVisualizer.print(tree, data.getDataset(),
new String[] {"sepallength", "sepalwidth", "petallength", "petalwidth",
"class"});
{code}
To check the route:
{code}
TreeVisualizer.predictTracePrint(tree, testData,
new String[] {"sepallength", "sepalwidth", "petallength", "petalwidth",
"class"});
{code}
The result for predictTracePrint.
{noformat}
(petallength = 4.7) >= 3.3 -> (petalwidth = 1.4) < 1.8 -> (petallength = 4.7) <
5 -> (petalwidth = 1.4) < 1.7 -> Iris-versicolor
{noformat}
In addition, ForestVisualizer can be used as a cli tool.
{noformat}
.. ForestVisualizer -ds dataset/iris.info -m model/iris -n sepallength
sepalwidth petallength petalwidth class
{noformat}
The result.
{noformat}
Tree[1]:
petallength < 3.5 : Iris-setosa
petallength >= 3.5
| petalwidth < 1.8
| | petallength < 5 : Iris-versicolor
| | petallength >= 5
| | | petalwidth < 1.7 : Iris-virginica
| | | petalwidth >= 1.7 : Iris-versicolor
| petalwidth >= 1.8
| | petallength < 4.9
| | | sepallength < 6 : Iris-versicolor
| | | sepallength >= 6 : Iris-virginica
| | petallength >= 4.9 : Iris-virginica
Tree[2]:
petallength < 3.3 : Iris-setosa
petallength >= 3.3
| petalwidth < 1.8
| | sepalwidth < 2.3 : Iris-virginica
| | sepalwidth >= 2.3
| | | petallength < 5.6
| | | | sepallength < 5.5
| | | | | sepalwidth < 2.5 : Iris-versicolor
| | | | | sepalwidth >= 2.5 : Iris-virginica
| | | | sepallength >= 5.5 : Iris-versicolor
| | | petallength >= 5.6 : Iris-virginica
| petalwidth >= 1.8 : Iris-virginica
Tree[3]:
petallength < 3.3 : Iris-setosa
petallength >= 3.3
| petalwidth < 1.8
| | petallength < 5 : Iris-versicolor
| | petallength >= 5
| | | petalwidth < 1.7 : Iris-virginica
| | | petalwidth >= 1.7 : Iris-versicolor
| petalwidth >= 1.8 : Iris-virginica
Tree[4]:
.
-snip-
.
{noformat}
All trees in the forest are dumped.
> Add the Tree/Forest Visualizer
> ------------------------------
>
> Key: MAHOUT-926
> URL: https://issues.apache.org/jira/browse/MAHOUT-926
> Project: Mahout
> Issue Type: Improvement
> Components: Classification
> Reporter: Ikumasa Mukai
> Labels: test
> Attachments: MAHOUT-926.patch
>
>
> TreePrinter and ForestPrinter are made for checking the model on MAHOUT-840.
> I think they are useful for checking the model and making unit testing.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira