Reputation: 4295
I have a data frame loaded into R.
I am still a beginner with R.
I have installed the e1071 package to use the svm function.
However, i am unsure of which parameters are mapping to which. I would like to have a model with the parameters as per in weka.
I do not understand the e1071 svm example as the example does not work.
svm(x, y = NULL, scale = TRUE, type = NULL, kernel =
+ "radial", degree = 3, gamma = if (is.vector(x)) 1 else 1 / ncol(x),
+ coef0 = 0, cost = 1, nu = 0.5,
+ class.weights = NULL, cachesize = 40, tolerance = 0.001, epsilon = 0.1,
+ shrinking = TRUE, cross = 0, probability = FALSE, fitted = TRUE,
+ ..., subset, na.action = na.omit)
Error: '...' used in an incorrect context
i currently have this code
x <- read.arff("contact-lenses.arff")
where i loaded my arff into a data frame x.
However, i am unsure of how to continue to use the same parameters as in weka to build the model as in R.
Any help rendered is greatly appreciated.
This is what i tried.
model <- svm(x, y = NULL, scale = TRUE, type = "C-classification", kernel = "linear")
Error in if (any(co)) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In FUN(newX[, i], ...) : NAs introduced by coercion
2: In FUN(newX[, i], ...) : NAs introduced by coercion
3: In FUN(newX[, i], ...) : NAs introduced by coercion
4: In FUN(newX[, i], ...) : NAs introduced by coercion
5: In FUN(newX[, i], ...) : NAs introduced by coercion
To be honest, i am unsure of some of the parameters like what does it mean by y = NULL. I am literally hitting at random air trying to get it to work.
I have resolved it using the below answer
model <- svm(`contact-lenses` ~ . , data = x, type = "C-classification", kernel = "linear")
Upvotes: 0
Views: 2499
Reputation: 1484
The error you get is because the y = NULL
means that you aren't actually providing any labels to learn.
Try the following, assuming this is the same contact-lenses.arff file I found via google:
model <- svm(`contact-lenses` ~ . , data = x, type = "C-classification", kernel = "linear")
The first parameter, "`contact-lenses` ~ .", is a formula, and means that you will be predicting the contact-lenses status versus based on all the other features. The backticks around the feature name are necessary because the feature inconveniently has a hyphen in it, which would otherwise be interpreted as subtraction. The data = x
parameter means that you will be using x as the underlying data frame to resolve the feature names against.
Upvotes: 2