CD.2: Principal Components AnalysisCD.2: Principal Components Analysis
Sample R code for Principal Component Analysis
PCTexture <- prcomp(TxPredLib, scale=T) print(PCTexture) summary(PCTexture) par(mfrow=c(1,1), oma = c(1,1,0,0) + 0.1, mar = c(3,3,1,1) + 0.1) plot(PCTexture, type="line", col=c("dark blue"), main="", pch=19) ## Scree plot mtext("Screeplot of Texture", side=1, line=3, cex=0.8) biplot(PCTexture, pch=19, cex=0.6, col=c("olivedrab1", "blue")) TextureScore <- PCTexture$x[,1:8] TextureMasterPCScore <- cbind(TextureScore, TxClassLib) # Used for model fitting and 10-fold cross-validation
With such a high degree of dependency it is recommended that a PCA is done on the data and only the top few components are used for classification.
From the table and the screeplot above it is clear that it is sufficient to consider only the first 8 PCs. They are given below.
For classification, therefore, only the first 8 PCs will be used, instead of all the 40 attributes.