svg(filename='Rplots.svg',width=6,height=5,onefile=TRUE,
antialias=c('default','none','gray','subpixel'))
library('MASS'); library('nnet')
data(Boston); n<-dim(Boston)[1]
model<-nnet(as.matrix(Boston[1:430,-14]),
as.matrix(Boston[1:430,14]),
size=65,trace=F,maxit=2*10^3,linout=T,decay=.1^3)
predictions<-predict(model,as.matrix(Boston[431:n,-14]),type='raw')
plot(as.matrix(Boston[431:n,14]),col='#3636ff',type='o',
ylab='targets & predictions',yaxt='n'); par(new=TRUE)
plot(predictions,col='#ff3636',type='o',cex=1.3,
ylab='targets & predictions',ylim=c(0,60))
legend(10,55,legend=c('targets','predictions'),
col=c('#3636ff','#ff3636'),lty=c(1,1)); dev.off()
No comments:
Post a Comment