R language Access Menu

Creating algorithm using classfication and trees

In this interesting technique, it is possible to analyze the data and create an algorithm by which the decision regarding outcome variable is reached by analyzing the predictor variables. 

Code:

> library(rpart)
> fit = rpart(low~., data=bwdf, method='class')
> plot(fit)
> text(fit)
> fit
n= 189 
node), split, n, loss, yval, (yprob)
      * denotes terminal node

     1) root 189 59 0 (0.6878307 0.3121693)  
    2) ptl< 0.5 159 41 0 (0.7421384 0.2578616)  
         4) lwt>=106 131 28 0 (0.7862595 0.2137405)  
      8) ht=0 122 23 0 (0.8114754 0.1885246) *
      9) ht=1 9  4 1 (0.4444444 0.5555556) *
         5) lwt< 106 28 13 0 (0.5357143 0.4642857)  
      10) age< 22.5 18  5 0 (0.7222222 0.2777778) *
      11) age>=22.5 10  2 1 (0.2000000 0.8000000) *
       3) ptl>=0.5 30 12 1 (0.4000000 0.6000000)  
         6) lwt>=131.5 9  3 0 (0.6666667 0.3333333) *
         7) lwt< 131.5 21  6 1 (0.2857143 0.7142857) *

               


    Comments & Feedback