0

Trying to get class probabilites of dependent variable through following codes using caret library and method "svm-radial". I have tried it on iris data set.

    # finding optimal value of a tuning parameter
      sigDist <- sigest(Species ~ . , data=Train, frac=1)
    # creating a grid of two tuningparameters, .sigma comes from the earlier line.
    # we are trying to find best value of C
      svmTuneGrid <- data.frame(.sigma=sigDist[1], .C=2^(-2:7))

     model_svmRadial <- train(Species ~. , data=Train, method='svmRadial', preProc=c("center","scale"),tuneGrid=svmTuneGrid , trControl=myControl,classProbs=TRUE)

Its producing errors and warnings:

    model_svmRadial <- train(Species ~. , data=Train, method='svmRadial', preProc=c("center","scale"),tuneGrid=svmTuneGrid , trControl=myControl,classProbs=TRUE)
     Something is wrong; all the Accuracy metric values are missing:
     Accuracy       Kappa    
       Min.   : NA   Min.   : NA  
       1st Qu.: NA   1st Qu.: NA  
       Median : NA   Median : NA  
       Mean   :NaN   Mean   :NaN  
       3rd Qu.: NA   3rd Qu.: NA  
       Max.   : NA   Max.   : NA  
       NA's   :10    NA's   :10   
       Error in train.default(x, y, weights = w, ...) : Stopping
       In addition: There were 31 warnings (use warnings() to see them)

Removing classProbs=TRUE , train function is working fine . But I need the class probabilities. Please suggest how to get rid of error. Thanks in anticipation.

phiver
  • 23,048
  • 14
  • 44
  • 56
shan
  • 553
  • 2
  • 9
  • 25
  • Possible duplicate of [Caret and KNN in R: predict function gives error](http://stackoverflow.com/questions/33200033/caret-and-knn-in-r-predict-function-gives-error) – phiver Oct 23 '15 at 09:19

1 Answers1

1

You should put classProbs inside your trainControl not inside train, for example:

myControl <- trainControl(method= "cv",
                          number = 10,
                          classProbs = TRUE) 
howaj
  • 685
  • 5
  • 10