This page contains a guide the many options for visualizing tree learners.
write_html function allows you to construct an interactive browser visualization of a tree learner:
In a Jupyter notebook, tree learners are automatically visualized in this way. If you are working from a terminal, you can open a browser window with a visualization of any tree learner using
write_questionnaire function allows you to create an interactive questionnaire from a tree learner.
You can open a browser window with the questionnaire for any tree learner using
It is possible to combine many learners into a single interactive visualization that will present the user with the ability to change between the trees. We combine the learners as follows:
- a question is a
Pairof the form
question => responseswhere
questionis the string prompt for the question and
responsesis a vector of possible responses
- each response is also a
Pairof the form
answer => nextwhere
answeris the string answer for this option, and
nextindicates how to proceed if this response is selected. The possible options for
- another question to continue presenting options
- a tree learner to visualize
The following example prepares a series of questions to choose between a group of learners:
questions = ("Use tree" => [ "with hyperplanes" => lnr_hyper, "without hyperplanes" => ("and maximum depth" => [ "1" => lnr_nohyper_depth1, "2" => lnr_nohyper_depth2, ]), ])
write_png function allows you to visualize a tree learner as a PNG image:
Note that this requires you have GraphViz installed and on the system
PATH. If you do not, you can use
write_dot to export the tree in .dot format and use GraphViz to render it as a PNG image at a later time.
When displaying the tree in the terminal or as an image, if the observations with missing observations goes to the lower child, the split message will say
is missing in addition to the split criterion. Otherwise, no explicit message is displayed regarding the missing data direction.
Fitted OptimalTreeClassifier: 1) Split: XS3obtfU < 39.34 2) Split: Fr8w5mB0 ≤ 3 or is missing 3) Predict: 1 (92.66%), [8,101], 109 points, error 8 4) Predict: 0 (100.00%), [43,0], 43 points, error 0 5) Split: zAPikvQB is missing 6) Predict: 1 (91.11%), [8,82], 90 points, error 8 7) Predict: 0 (91.86%), [237,21], 258 points, error 21
In the interactive tree visualization, the child node that receives data with missing values is denoted by a small dot on top of the node.