r - The meaning of predict(rpart.model) -


given that:

data(iris) fit <- rpart(species~., iris) predict(fit) 

does give cross-validated prediction of training data?

i did not find confirmation cv prediction in rpart documentation.

10x

using predict(fit) predicted class probabilities (for classification trees; means regression trees) on training data set. tree used prediction shown by

fit  ## n= 150  ##  ## node), split, n, loss, yval, (yprob) ##       * denotes terminal node ##  ## 1) root 150 100 setosa (0.33333333 0.33333333 0.33333333)   ##   2) petal.length< 2.45 50   0 setosa (1.00000000 0.00000000 0.00000000) * ##   3) petal.length>=2.45 100  50 versicolor (0.00000000 0.50000000 0.50000000)   ##     6) petal.width< 1.75 54   5 versicolor (0.00000000 0.90740741 0.09259259) * ##     7) petal.width>=1.75 46   1 virginica (0.00000000 0.02173913 0.97826087) * 

during fitting of tree cross-validation carried out, e.g., at

fit$cptable  ##     cp nsplit rel error xerror       xstd ## 1 0.50      0      1.00   1.16 0.05127703 ## 2 0.44      1      0.50   0.70 0.06110101 ## 3 0.01      2      0.06   0.09 0.02908608 

so in case fit had lowest cross-validation error (see xerror column). on other data sets may need apply additional pruning or use 1-se pruning rule etc.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -