Your output has:

"At least one of the class levels are not valid R variables names; This may
cause errors if class probabilities are generated because the variables
names will be converted to: X0, X1"

Try changing the factor levels to avoid leading numbers and try again.

Max




On Thu, Nov 29, 2012 at 10:18 PM, Brian Feeny <bfe...@mac.com> wrote:

>
>
> Yes I am still getting this error, here is my sessionInfo:
>
> > sessionInfo()
> R version 2.15.2 (2012-10-26)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] e1071_1.6-1     class_7.3-5     kernlab_0.9-14  caret_5.15-045
>  foreach_1.4.0   cluster_1.14.3
> [7] reshape_0.8.4   plyr_1.7.1      lattice_0.20-10
>
> loaded via a namespace (and not attached):
> [1] codetools_0.2-8 compiler_2.15.2 grid_2.15.2     iterators_1.0.6
> tools_2.15.2
>
>
> Is there an example that shows a classProbs example, I could try to run it
> to replicate and see if it works on my system.
>
> Brian
>
> On Nov 29, 2012, at 10:10 PM, Max Kuhn <mxk...@gmail.com> wrote:
>
> You didn't provide the results of sessionInfo().
>
> Upgrade to the version just released on cran and see if you still have the
> issue.
>
> Max
>
>
> On Thu, Nov 29, 2012 at 6:55 PM, Brian Feeny <bfe...@mac.com> wrote:
>
>> I have never been able to get class probabilities to work and I am
>> relatively new to using these tools, and I am looking for some insight as
>> to what may be wrong.
>>
>> I am using caret with kernlab/ksvm.  I will simplify my problem to a
>> basic data set which produces the same problem.  I have read the caret
>> vignettes as well as documentation for ?train.  I appreciate any direction
>> you can give.  I realize this is a very small dataset, the actual data is
>> much larger, I am just using 10 rows as an example:
>>
>> trainset <- data.frame(
>>   outcome=factor(c("0","1","0","1","0","1","1","1","1","0")),
>>   age=c(10, 23, 5, 28, 81, 48, 82, 23, 11, 9),
>>   amount=c(10.11, 22.23, 494.2, 2.0, 29.2, 39.2, 39.2, 39.0, 11.1, 12.2)
>> )
>>
>> > str(trainset)
>> 'data.frame':   7 obs. of  3 variables:
>>  $ outcome: Factor w/ 2 levels "0","1": 2 1 2 2 2 2 1
>>  $ age    : num  23 5 28 48 82 11 9
>>  $ amount : num  22.2 494.2 2 39.2 39.2 ...
>>
>> > colSums(is.na(trainset))
>> outcome     age  amount
>>       0       0       0
>>
>>
>> ## SAMPLING AND FORMULA
>> dataset <- trainset
>> index <- 1:nrow(dataset)
>> testindex <- sample(index, trunc(length(index)*30/100))
>> trainset <- dataset[-testindex,]
>> testset <- dataset[testindex,-1]
>>
>>
>> ## TUNE caret / kernlab
>> set.seed(1)
>> MyTrainControl=trainControl(
>>   method = "repeatedcv",
>>   number=10,
>>   repeats=5,
>>   returnResamp = "all",
>>   classProbs = TRUE
>> )
>>
>>
>> ## MODEL
>> rbfSVM <- train(outcome~., data = trainset,
>>                method="svmRadial",
>>                preProc = c("scale"),
>>                tuneLength = 10,
>>                trControl=MyTrainControl,
>>                fit = FALSE
>> )
>>
>> There were 50 or more warnings (use warnings() to see the first 50)
>> > warnings()
>> Warning messages:
>> 1: In train.default(x, y, weights = w, ...) :
>>   At least one of the class levels are not valid R variables names; This
>> may cause errors if class probabilities are generated because the variables
>> names will be converted to: X0, X1
>> 2:  In caret:::predictionFunction(method = method, modelFit = mod$fit,
>>  ... :
>>   kernlab class prediction calculations failed; returning NAs
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
>
> Max
>
>
>


-- 

Max

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to