Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Visualizing classification and regression trees

    Can we visualize classification and regression trees (CART) in Stata? I've found two user-written commands -- cart and crtrees -- but I'm not sure either will visualize the tree. Here's a summary of what I've learned:

    crtrees. The following code (from help crtrees) produces a textual description of the notes, rather than graphical tree.
    Code:
    ssc install crtrees
    sysuse auto, clear
    crtrees price trunk weight length foreign gear_ratio, seed(12345)
    The last line also produces an error:
    estimates post: matrix has missing values
    cart. It appears this command, last updated in 2004, was not a complete implementation of CART but intended only for failure-time data. I couldn't get it working and there are no examples in the help file, but the documentation doesn't suggest that it visualizes the tree.....
    Code:
    ssc install cart
    help cart

  • #2
    My impression matches yours: interest in this is restricted to community-contributed commands and those were often less general than they appeared.

    Speaking only personally, I found this work provocative and impressive in some ways, but never fully convincing. I sense that statistics and machine learning have moved in different directions so that CART became a glorious dead end.

    Comment


    • #3
      Fortunately, CART is not a dead end. Small CART trees can summarize patterns in data, often more intelligibly than logistic regression. In machine learning, it is common to average multiple CART trees in a "random forest," producing predictions that can be quite competitive with other methods.

      But back to my original question: I have a nice application for CART and wonder if there is a way to visualize CART trees graphically in Stata.

      Comment


      • #4
        Let me relay a reply from Stata Technical Support:
        We currently do not have command or options allowing to visualize CART
        output. One possibility is to use our Python integration feature to do
        this....
        It appears the user-written command treeplot uses Python integration to draw a CART tree:
        https://ideas.repec.org/c/boc/bocode/s459098.html

        Comment


        • #5
          It's strange and interesting for me that Stata have devoted time to develop Stata-Python integration since Stata 16, but switched to use H2O platform to support its machine learning module in Stata 19.
          The command -treeplot- is wrote by Giovanni Cerulli, and -c_ml_stata_cv-, -r_ml_stata_cv- maybe also helpful. These commands all use the Stata/Python integration (sfi) capability of Stata. Also see https://www.statalist.org/forums/for...egression-tree

          Comment

          Working...
          X