Skip to content

"Where" command in ctree (party)

5 messages · Achim Zeileis, Joseph Wang

#
On Fri, 17 Feb 2012, josephw wrote:

            
Without a reproducible example it is hard to say what is going on here. 
All columns of the learning and the test data need to have (a) the same 
name, (b) the same class, (c) the same levels in case they are factors.
#
I was able to narrow down to a column that has different types using 

featurefields<-c(7, 17, 19, 20, 22, 33, 35, 36, 38, 44:132)
flag <- rep(0, ncol(data))
for (i in featurefields) {
	flag[i] <- class(data[,i]) != class(validdata[,i])
}


It is an integer class in the training data but is numeric in the validation data even though
unique(valid[,88]) shows 0 and 1.


-----Original Message-----
From: Achim Zeileis [mailto:Achim.Zeileis at uibk.ac.at] 
Sent: Friday, February 17, 2012 10:51 AM
To: Joseph Wang
Cc: r-help at r-project.org
Subject: Re: [R] "Where" command in ctree (party)
On Fri, 17 Feb 2012, josephw wrote:

            
Without a reproducible example it is hard to say what is going on here. 
All columns of the learning and the test data need to have (a) the same name, (b) the same class, (c) the same levels in case they are factors.
#
On Fri, 17 Feb 2012, Joseph Wang wrote:

            
A construct like

which(sapply(data, class) != sapply(validdata, class))

might also help.
Hopefully valid[,88] <- as.integer(valid[,88]) should then resolve the 
problems.
Z