5

I am trying to perform classification using R's adabag package.

The following call works perfectly with R's ada package's ada() function.

model<-ada(factor(label)~., data=trainingdata)

But when the same training data set is used in the following adabag's function call, it returns an error:

model<-boosting(factor(label)~., data=trainingdata)

Error in `[.data.frame`(data, , as.character(formula[[2]])) : 
undefined columns selected

What this error suggests exactly?

Shahzad
  • 1,999
  • 6
  • 35
  • 44
  • It suggests that in the dataframe `trainingdata` that there is no column named `factor(label)`. – IRTFM Apr 01 '13 at 23:31
  • Maybe if you have a data frame `trainingdata` you can try `model<-boosting(factor(trainingdata$label)~., data=trainingdata)` – Duck Apr 02 '13 at 00:00
  • 3
    I suspect the solution might be to perform the factor operation before the boosting call: `trainingdata$label <- factor( trainingdata$label); (bmodel<-boosting(factor(label)~., data=trainingdata) )` . I've noticed that a lot of the 'machine learning' packages either do not have formula interfaces or that they are incompletely implemented. – IRTFM Apr 02 '13 at 00:12

1 Answers1

4

I get exactly that error message when running a minor modification of boosting's first example:

> data(iris)
> iris.adaboost <- boosting(factor(Species)~., data=iris, boos=TRUE, mfinal=10)
Error in `[.data.frame`(data, , as.character(formula[[2]])) : 
  undefined columns selected

So you should try the advice I just gave in a comment (to do the factor()-ing beforehand). The formula interface to boosting is not full featured enough to even handle the factor function in its parse-tree.

IRTFM
  • 258,963
  • 21
  • 364
  • 487