Dataset: https://archive.ics.uci.edu/ml/datasets/Chess+%28King-Rook+vs.+King-Pawn%29
Code:
require("e1071")
# Load the data into bank
bank <- read.csv("~/R/SVM/kr-vs-kp.data")
colnames(bank)[ncol(bank)] <- 'to.classify'
bank$to.classify <- as.factor(bank$to.classify)
# Divide the data into TRAIN and TEST sets
index <- 1:nrow(bank)
testIndex <- sample(index, trunc(length(index)/3))
testSet <- bank[testIndex,]
trainSet <- bank[-testIndex,]
# Learning sigmoid tuned nu-classification model
svm.nu.tune.model.sigmoid <- best.svm(to.classify ~ ., data = trainSet, coef0 = c(0,1,10,20,30), gamma = c(0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30), cost = c(1,3,10,30,100), nu = c(0.1,0.3,0.5,0.7,0.9), na.action = na.omit, kernel = 'sigmoid', type = 'nu-classification')
print(svm.nu.tune.model.sigmoid)
Error:
Error in predict.svm(ret, xhold, decision.values = TRUE) :
NA/NaN/Inf in foreign function call (arg 8)
The algorithm works fine on any other combination of kernel and type. This is the only problematic one.
The problem appears to be that you mix the parameters in the same call. If you just use the nu parameter with the nu-classification (and cost parameter with C-classification in another call) then it should work.
For example: