# Esempio 0 con la potatura
par(mfrow=c(1,1),mar=c(4,4,2,2))
# name    - Manufacturer and model
# syct    - cycle time in nanoseconds
# mmin    - minimum main memory in kilobytes
# mmax    - maximum main memory in kilobytes
# cach    - cache size in kilobytes
# chmin   - minimum number of channels
# chmax   - maximum number of channels
# perf    - published performance on a benchmark mix relative to an IBM 370/158-3
# estperf - estimated performance (by Ein-Dor & Feldmesser)
data(cpus, package="MASS")
attach(cpus)
summary(cpus)
# regression tree
library(rpart)
rpart.control(minsplit=10, minbucket=3, cp=0.005, 
              maxcompete=4, maxsurrogate=5, usesurrogate=2, xval=10,
              surrogatestyle=0, maxdepth=30)
Cpu.tr <- rpart(log10(perf)~syct+mmin+mmax+cach+chmin+chmax,method="anova",data=cpus)
printcp(Cpu.tr)
summary(Cpu.tr)
Cpu1.tr<-prune(Cpu.tr,cp=0.01)
#plot(Iscri1.tr,branch=0.25,margin=0.05);text(Iscri1.tr,digits=2)
post(Cpu1.tr,file="",title="Performance",pretty=TRUE,use.n=F,digits=2)



