For experimental purpose, I want to intentionally over-fit my training data with CART. But with
rpart in R. I cannot achieve 100% accuracy. Why?
table(d$classes,predict(fit,d, type="class")) 1 2 1 2544 21 2 33 2402
The data is generated from 2 Gaussian, so, there is no chance the two data points with different class label would overlap, and we set the complexity parameter to 0 and min split is 1. As discussed in the comment. I tried every combinations with the
control (not shown in the code), but not helpful.
Why there are still pruning happend on the tree? Or why the tree stop to grow to achivive 100% accuracy?
library(mlbench) library(rpart) set.seed(0) graphics.off() par(mfrow=c(2,2)) d=mlbench.2dnormals(5000,sd=3) ctr=rpart.control(cp=0,minsplit = 1) fit=rpart(classes~.,d,control=ctr) table(d$classes,predict(fit,d, type="class")) gd=seq(-8,8,0.1) dnew=expand.grid(x.1=gd,x.2=gd) plot(d,xlim=c(-8,8),ylim=c(-8,8)) grid() plot(dnew$x.1,dnew$x.2,col=predict(fit,dnew, type="class")) plotcp(fit) grid()