
R : Copyright 2005, The R Foundation for Statistical Computing
Version 2.1.1  (2005-06-20), ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for a HTML browser interface to help.
Type 'q()' to quit R.

> invisible(options(echo = TRUE))
> train <- read.table("loans.dat",header=F,col.names=c("x1","x2","y"));
> 
> x1 <- train$x1;
> x2 <- train$x2;
> 
> one <- mat.or.vec(length(x1),1) + 1.0;
> X <- cbind(one,x1,x2)
> y  <- train$y;
> 
> fit <- lsfit(X,y,intercept=FALSE);
> b <- as.numeric(fit$coef);
> yhat <- y - fit$residuals
> 
> test <- read.table("eval.dat",header=F,col.names=c("x1","x2","y"));
> 
> tx1 <- test$x1;
> tx2 <- test$x2;
> ty  <- test$y;
> 
> one <- mat.or.vec(length(tx1),1) + 1.0;  
> X <- cbind(one,tx1,tx2)
> 
> pred <- X%*%b; 
> dflt <- (pred > 0.5);
> 
> dflt <- as.numeric(dflt);
> 
> err <- abs(dflt-ty);
> print(mean(err));
[1] 0.07854
> 
> library(rpart);
> 
> augmented <- data.frame(cbind(y,x1,x2,yhat))
> 
> fit <- rpart(y ~ yhat, data=augmented, method="class", maxdepth=2);
> 
> #print(fit)
> #
> #print(fit$control)
> #
> #asource("psopts.r");
> #postscript(file="boostl.eps");
> #
> #par(mar=c(0,0,0,0));
> #plot(fit);
> #text(fit);
> #par();
> #
> #dev.off();
> 
> test <- read.table("eval.dat",header=F,col.names=c("x1","x2","y"));
> 
> tx1 <- test$x1;
> tx2 <- test$x2;
> ty <- test$y;
> 
> dflt <-  (pred>=0.5248545) 
> 
> dflt <- as.numeric(dflt);
> 
> err <- abs(ty-dflt);
> print(mean(err));
[1] 0.07498
> 
> train <- read.table("loans.dat",header=F,col.names=c("x1","x2","y"));
> 
> x1 <- train$x1;
> x2 <- train$x2;
> 
> one <- mat.or.vec(length(x1),1) + 1.0;
> X <- cbind(one,x1,x2,x1*x2,x1^2,x2^2);
> y  <- train$y;
> 
> fit <- lsfit(X,y,intercept=FALSE);
> b <- as.numeric(fit$coef);
> yhat <- y - fit$residuals
> 
> test <- read.table("eval.dat",header=F,col.names=c("x1","x2","y"));
> 
> tx1 <- test$x1;
> tx2 <- test$x2;
> ty  <- test$y;
> 
> one <- mat.or.vec(length(tx1),1) + 1.0;  
> X <- cbind(one,tx1,tx2,tx1*tx2,tx1^2,tx2^2);
> 
> pred <- X%*%b; 
> dflt <- (pred > 0.5);
> 
> dflt <- as.numeric(dflt);
> 
> err <- abs(dflt-ty);
> print(mean(err));
[1] 0.07807
> 
> library(rpart);
> 
> augmented <- data.frame(cbind(y,x1,x2,yhat))
> 
> fit <- rpart(y ~ yhat, data=augmented, method="class", maxdepth=2);
> 
> #print(fit)
> #
> #print(fit$control)
> #
> #source("psopts.r");
> #postscript(file="boosta.eps");
> #
> #par(mar=c(0,0,0,0));
> #plot(fit);
> #text(fit);
> #par();
> #
> #dev.off();
> 
> test <- read.table("eval.dat",header=F,col.names=c("x1","x2","y"));
> 
> tx1 <- test$x1;
> tx2 <- test$x2;
> ty <- test$y;
> 
> dflt <-  (pred>=0.4294637) 
> 
> dflt <- as.numeric(dflt);
> 
> err <- abs(ty-dflt);
> print(mean(err));
[1] 0.07493
> 
> proc.time()
[1] 10.13  0.63 21.80  0.00  0.00
> 
