classplot {emu} | R Documentation |
The function classifies all point specified within the ranges of xlim and ylim based on the training model specified in model. It then produces a two-dimensional plot colour-coded for classifications.
classplot(model, xlim, ylim, N = 100, pch = 15, col = NULL, legend = TRUE, position = "topright", bg = "gray90", ...)
model |
A two-dimensional training model output from qda(), lda(), or svm() |
xlim |
A vector of two numeric elements specifying the range on the x-axis (parameter 1) over which classifications should be made |
ylim |
A vector of two elements specifying the range on the y-axis (parameter 2) over which classifications should be made |
N |
A vector of one numeric element which specifies the density of classification (greater N gives higher density). The default is 100. |
pch |
A single element numeric vector specifying the plotting symbol to be used in the classification plot. Defaults to 15. |
col |
Either Null in which case the colours for the separate classes are col = c(1, 2, ...n) where n is the number of classes; or else a vector specifying the desired colours that is the same length as there are classes. |
legend |
A single element logical vector specifying whether a legend should be drawn. Defaults to T |
position |
A single element vector specifying the position in the figure where the legend should be drawn. Defaults to "topright" |
bg |
A single element vector specifying the background colour on which the legend should be drawn. |
... |
Further arguments to plot. |
Jonathan Harrington
qda
, lda
, svm
. There is a function plot.svm
which produces a prettier plot for SVMs.
library(MASS) # Data from female speaker 68 temp = vowlax.spkr=="68" # Quadratic discriminant analysis fm.qda = qda(vowlax.fdat.5[temp,1:2], vowlax.l[temp]) # Linear discriminant analysis fm.lda = lda(vowlax.fdat.5[temp,1:2], vowlax.l[temp]) #library(e1071) # Support vector machine fm.svm = qda(vowlax.fdat.5[temp,1:2], factor(vowlax.l[temp])) xlim = range(vowlax.fdat.5[temp,1]) ylim = range(vowlax.fdat.5[temp,2]) par(mfrow=c(1,3)) classplot(fm.qda, xlim=xlim, ylim=ylim, main="QDA") classplot(fm.lda, xlim=xlim, ylim=ylim, main="LDA") classplot(fm.svm, xlim=xlim, ylim=ylim, xlab="F1", ylab="F2", main="SVM")