benhamner / MachineLearning.jl

Julia Machine Learning library
Other
116 stars 28 forks source link

adds pretty show for decision branches, with test #2

Closed dchudz closed 10 years ago

dchudz commented 10 years ago

This adds a nicer show method for DecisionBranch. So instead of getting:

DecisionBranch(1,0.5,DecisionBranch(2,1.5,DecisionBranch(3,2.5,RegressionLeaf(10.0),RegressionLeaf(12.0)),RegressionLeaf(20.0)),RegressionLeaf(30.0))

... you get:

DecisionBranch(1, 0.500000, 
|DecisionBranch(2, 1.500000, 
||DecisionBranch(3, 2.500000, 
|||RegressionLeaf(10.0) 
|||RegressionLeaf(12.0)) 
||RegressionLeaf(20.0)) 
|RegressionLeaf(30.0))

But it's possible the output of this will too many lines for you to want it as a default show method, though.

I also might not have thought through every case, so it's possible this isn't general enough? Anyway, won't be offended if you think this doesn't belong in the package, but here it is if you want it.