par(mfrow=c(1,1),mar=c(4,4,2,2))
###################################################
# CART o suddivisione ricorsiva binaria
#
# Produzioni di unità centrali per PC
# 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")
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)
#perf è la variabile dipendente
cpus.tr <- rpart(perf~syct+mmin+mmax+cach+chmin+chmax, data=cpus,method="anova")
post(cpus.tr,file="",title="Analisi binaria: Microprocessor Data",pretty=TRUE)
printcp(Cpu.tr)
summary(cpus.tr)
# Esecuzione sui logaritmi della risposta.
cpus.tr <- rpart(log10(perf)~syct+mmin+mmax+cach+chmin+chmax, data=cpus,method="anova")
post(cpus.tr,file="",title="Nei logaritmi",pretty=TRUE,use.n=F,digits=2)
summary(cpus.tr)



