car.test.frame <- read.table("c:\\temp\\car.test.frame.txt",header=T)
attach(car.test.frame)
attach(car.test.frame)
names(car.test.frame)
plot(Weight,Mileage,pch=21,col="brown",bg="green")
a <- mean(Mileage[Weight<2567.5])
b <- mean(Mileage[Weight>=2567.5])
lines(c(1500,2567.5,2567.5,4000),c(a,a,b,b))
car.model <- tree(Mileage~Weight)
wt <- seq(1500,4000)
y <- predict(car.model,list(Weight=wt))
plot(Weight,Mileage,pch=21,col="brown",bg="green")
lines(wt,y)
prune.tree(model)
plot(prune.tree(model))
model2 <- prune.tree(model,best=4)
plot(model2)
text(model2)
print(model2)