Extracting Information from the Decision Rules in rpart package
<p>I need to extract information from the rules in decision tree. I am using rpart package in R. I am using demo data in the package to explain my requirements: </p>

<pre><code>data(stagec)
fit&lt;- rpart(formula = pgstat ~ age + eet + g2 + grade + gleason + ploidy, data = stagec, method = "class", control=rpart.control(cp=0.05))
fit
</code></pre>

<p>printing fit shows </p>

<pre><code>n= 146 

node), split, n, loss, yval, (yprob)
      * denotes terminal node

 1) root 146 54 0 (0.6301370 0.3698630)  
   2) grade&lt; 2.5 61  9 0 (0.8524590 0.1475410) *
   3) grade&gt;=2.5 85 40 1 (0.4705882 0.5294118)  
     6) g2&lt; 13.2 40 17 0 (0.5750000 0.4250000)  
      12) ploidy=diploid,tetraploid 31 11 0 (0.6451613 0.3548387) *
      13) ploidy=aneuploid 9  3 1 (0.3333333 0.6666667) *
     7) g2&gt;=13.2 45 17 1 (0.3777778 0.6222222)  
      14) g2&gt;=17.91 22  8 0 (0.6363636 0.3636364) *
      15) g2&lt; 17.91 23  3 1 (0.1304348 0.8695652) *
</code></pre>

<p>e.g. I would like to get  information something like below for the 12th node </p>

<p>If grade>=2.5 and g2&lt; 13.2 and ploidy in (diploid,tetraploid) then class 0 is predicted with 65% confidence. Any pointers on this would be very helpful.</p>

<p>Thanks</p>