Lekshman Ramesh
viz_machine=function(train_red){
for (i in 1:(ncol(train_red)-1)) {
Title <- paste("% Satisfied by ", names(train_red)[i], sep="")
train_red1=train_red[train_red[,i]<=quantile(train_red[,i],0.995)&train_red[,i]>=quantile(train_red[,i],0.005),]
tab1=data.frame(prop.table(table(train_red1[,i],train_red1$TARGET),1))
tab2=tab1[tab1$Var2==1,-c(2)]
plot2=ggplot(data=train_red1,aes(x=train_red1[,i]))+geom_histogram(stat="bin",bins=100) +theme(axis.text.y = element_blank())+ggtitle("")+scale_x_continuous(name="Values")
plot1= ggplot(data=tab2, aes(x=Var1, y=Freq, group=1)) +geom_point()
+stat_smooth(method="lm",formula=y~poly(x,2),color="red",se=F)+
stat_smooth(method="lm",formula=y~sqrt(x),color="green",se=F)
+ggtitle(Title)+scale_x_discrete(name="")+scale_y_continuous(name="% Satisfied")+
theme(legend.position="none", axis.text.y=element_blank(),
plot.title=element_text(hjust=0.5))
jpeg(paste(names(train_red)[i],".jpeg",sep=""))
grid.arrange(plot1,plot2, nrow=2)
dev.off()
}