[R] Getting runtime error in stepclass
ligges at statistik.uni-dortmund.de
Tue Jul 5 15:58:29 CEST 2005
Uwe Ligges wrote:
> Soma Saha wrote:
>> I got the following runtime error when I tried to use svm method with
>> Error in "colnames<-"(`*tmp*`, value = c("0", "1")) :
>> attempt to set colnames on object with less than two dimensions
>> I repeated the same sequence of statements but this time I used the
>> classification function used in the example, i.e., "lda" and it worked
>> fine but I got the same error when I tried randomForest.
>> As the same script worked with a different classification function, I am
>> wondering if stepclass works with svm and randomForest.
>> I using R version 2.0.1 on a Linux machine. I am including the R script I
>> used below.
>> I would be grateful for any suggestion on how to make stepclass work with
>> these classification functions.
>> I would also like to make stepclass work with knn but knn does not have a
>> 'predict' method, which is a requirement for a classification method to
>> work with stepclass. Is there any way to get around this?
>> td <- read.table("dgdata1.txt", header=TRUE, sep=",")
>> dgenes <- subset(td, dg == 1, select = dg:eg)
>> ndgenes <- subset(td, dg == 0, select = dg:eg)
>> n1 <- nrow(dgenes)
>> n2 <- nrow(ndgenes)
>> ndgrows <- 1:n2
>> selrows <- sample(ndgrows)
>> sndgenes <- ndgenes[selrows[1:n1],]
>> train <- rbind(dgenes, sndgenes)
>> traind <- subset(train, select = -dg)
>> trainr <- factor(dg)
>> sc_res <- stepclass(traind, trainr, "svm", direction = "forward",
>> criterion = "AC", fold = 10)
> Looks like predict.svm does not always return "probabilities" in all
> cases, hence cannot be used in your case, I guess.
> svmlight (interface in in packages klaR) will do, though. You also might
> want to use sknn() (also package klaR), since it has a predict method
> rather than knn().
> For randomForest, we will enhance stepclass() to support it in future.
I just told nonsense, stepclass() does not make sense with
randomForest(), obviously ... (wonder why nobody shouted?)
> Uwe Ligges
>> R-help at stat.math.ethz.ch mailing list
>> PLEASE do read the posting guide!
More information about the R-help