# # Epage 126 # Epage 134 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- source("load_vowel_data.R") source("reduced_rank_LDA.R") out = load_vowel_data( FALSE, FALSE ) XTrain = out[[1]] yTrain = out[[2]] XTest = out[[3]] yTest = out[[4]] out = reduced_rank_LDA( XTrain, yTrain, XTest, yTest ) K = length(unique(yTrain)) # the number of classes (expect the classes to be labeled 1, 2, 3, ..., K-1, K XTProj = out[[1]] MSProj = out[[3]] #postscript("../../WriteUp/Graphics/Chapter4/dup_fig_4_8_17.eps", onefile=FALSE, horizontal=FALSE) x_plot_coordinate = 1 y_plot_coordinate = 7 plot_colors = c("black","blue","brown","purple","orange","cyan","gray","yellow","black","red","green") for( ci in 1:K ){ inds = yTrain == ci if( ci==1 ){ plot( XTProj[inds,x_plot_coordinate], XTProj[inds,y_plot_coordinate], xlab="Coordinate 1 for Training Data", ylab="Coordinate 2 for Training Data", col=plot_colors[ci], type="p", xlim=range(XTProj[,x_plot_coordinate]), ylim=range(XTProj[,y_plot_coordinate]) ) lines( MSProj[ci,x_plot_coordinate], MSProj[ci,y_plot_coordinate], col=plot_colors[ci], type="p", cex=10, pch="." ) }else{ lines( XTProj[inds,x_plot_coordinate], XTProj[inds,y_plot_coordinate], xlab="Coordinate 1 for Training Data", ylab="Coordinate 2 for Training Data", col=plot_colors[ci], type="p" ) lines( MSProj[ci,x_plot_coordinate], MSProj[ci,y_plot_coordinate], col=plot_colors[ci], type="p", cex=10, pch="." ) } } #dev.off()