Entering edit mode
Javier Pérez Florido
▴
840
@javier-perez-florido-3121
Last seen 6.8 years ago
Dear list,
According to the example given in "compare" help page for CMA package,
I've executed the following code:
### compare the performance of several discriminant analysis methods
### for the Khan dataset:
data(khan)
khanX <- as.matrix(khan[,-1])
khanY <- khan[,1]
set.seed(27611)
fiveCV10iter <- GenerateLearningsets(y=khanY, method = "CV", fold
=
5, niter = 2, strat = TRUE)
### candidate methods: DLDA, LDA, QDA, pls_LDA, sclda
class_dlda <- classification(X = khanX, y=khanY, learningsets =
fiveCV10iter, classifier = dldaCMA)
### peform GeneSlection for LDA, FDA, QDA (using F-Tests):
genesel_da <- GeneSelection(X=khanX, y=khanY, learningsets =
fiveCV10iter, method = "f.test")
###
class_lda <- classification(X = khanX, y=khanY, learningsets =
fiveCV10iter, classifier = ldaCMA, genesel= genesel_da, nbgene = 10)
class_qda <- classification(X = khanX, y=khanY, learningsets =
fiveCV10iter, classifier = qdaCMA, genesel = genesel_da, nbgene = 2)
### We now make a comparison concerning the performance (sev.
measures):
### first, collect in a list:
dalike <- list(class_dlda, class_lda, class_qda)
### use pre-defined compare function:
comparison <- compare(dalike, plot = TRUE, measure =
c("misclassification", "brier score", "average probability"))
print(comparison)
## End(Not run)
Everyhing is OK. However, if I add a new classification method using
SVM
like this:
class_svm<- classification(X = khanX, y=khanY, learningsets =
fiveCV10iter, classifier = svmCMA, genesel = genesel_da, nbgene =
2,kernel="radial")
classifierlist <- list(class_dlda, class_lda, class_qda, class_svm)
par(mfrow = c(4, 1))
comparison <- compare(classifierlist, plot = TRUE, measure =
c("misclassification", "brier score", "average probability"))
I got the following error in compare function:
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
Any tips?
Thanks in advance,
Javier
> sessionInfo()
R version 2.10.0 (2009-10-26)
i386-pc-mingw32
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MASS_7.3-3 class_7.3-1 CMA_1.4.1 Biobase_2.6.0
e1071_1.5-20
loaded via a namespace (and not attached):
[1] tools_2.10.0