• Please complete the contact form below with details about your inquiry and I'll get back to you as soon as possible.

  • This field is for validation purposes and should be left unchanged.

Solution: kernlab class probability calculations failed; returning NAs

Howdy! I’m putting this down here for my future reference, as well as for anyone who has spent the couple hours looking for a solution:

kernlab class probability calculations failed; returning NAs

You get this error because you need to use a formula to define your model. For example:

fit.svm.radial <- train(data.train[,!(names(data.train) %in% c('value_change'))], data.train$value_change, 
                method='svmRadial', 
                trControl=objControl,  
                metric = "ROC",
                tunegrid=tunegrid,
                preProcess = NULL
                )

needs to be changed to:

fit.svm.radial <- train(value_change~., data=data.train, 
                method='svmRadial', 
                trControl=objControl,  
                metric = "ROC",
                tunegrid=tunegrid,
                preProcess = NULL
                )

If you found this helpful, let me know in the commentary section below 🙂

3 Comments

  1. Michael H

    Thanks for your contribution. I spent hours changing the random seed, but it didn’t work. This solution works!

Leave a Reply

Your email address will not be published. Required fields are marked *