0
votes

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.

1

1 Answers

1
votes

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

myControl <- trainControl(method= "cv",
                          number = 10,
                          classProbs = TRUE)