I'm trying to complete tuning for an SVM model in R, using the Titanic Kaggle dataset.
When I run the following code:
tune.out = tune(svm, Survived ~ Pclass + Sex + Age + Fare + Embarked + family,
data = boat, kernel = "linear",
ranges = list(cost = c(0.001, 0.01, 0.1, 1, 5, 10, 100)))
I get the error:
Error in names(ret2) <- rowns :
'names' attribute [90] must be the same length as the vector [71]
With the traceback:
3: predict.svm(model, if (!is.null(validation.x)) validation.x else if (useFormula) data[-train.ind[[sample]],
, drop = FALSE] else if (inherits(train.x, "matrix.csr")) train.x[-train.ind[[sample]],
] else train.x[-train.ind[[sample]], , drop = FALSE])
2: predict.func(model, if (!is.null(validation.x)) validation.x else if (useFormula) data[-train.ind[[sample]],
, drop = FALSE] else if (inherits(train.x, "matrix.csr")) train.x[-train.ind[[sample]],
] else train.x[-train.ind[[sample]], , drop = FALSE])
1: tune(svm, Survived ~ Pclass + Sex + Age + Fare + Embarked + family,
data = boat, kernel = "linear", ranges = list(cost = c(0.001,
0.01, 0.1, 1, 5, 10, 100)))
I understand that something might be wrong with my variables -- any thought of what that might be?
If it helps, I haven't modified any of the variables but have dropped a bunch (those not seen in the tuning formula and created a new variable family
by:
boat$family = boat$SibSp + boat$Parch
boat$family[boat$family > 0] = 1
Boat is a data.table
.