I was writing a code using sim with polynomial kernel. The code is as follows.
library(ISLR)
library(e1071)
library(randomForest)
library(class)
library(ggplot2)
library(GGally)
train = subset(wifiLocDat, Loc3 == TRUE)
test = subset(wifiLocDat, Loc3 == FALSE)
set.seed(4343)
tune.out <- tune(svm, wifiLocDat$Loc3~wifiLocDat$WiFi1 + wifiLocDat$WiFi2 + wifiLocDat$WiFi3 + wifiLocDat$WiFi4 + wifiLocDat$WiFi5 + wifiLocDat$WiFi6 + wifiLocDat$WiFi7, data=wifiLocDat, kernel="polynomial", ranges=list(degree=c(1,2,3,4,5,6)))
summary(tune.out)
svmPoly <- svm(Train$Loc3~., data=Train, kernel="polynomial",coef0=1,degree = 3)
dput(head(wifiLocDat,20)) structure(list(WiFi1 = c(-64L, -68L, -63L, -61L, -63L, -64L, -65L, -61L, -65L, -62L, -67L, -65L, -63L, -66L, -61L, -67L, -63L, -60L, -60L, -62L), WiFi2 = c(-56L, -57L, -60L, -60L, -65L, -55L, -61L, -63L, -60L, -60L, -61L, -59L, -57L, -60L, -59L, -60L, -56L, -54L, -58L, -59L), WiFi3 = c(-61L, -61L, -60L, -68L, -60L, -63L, -65L, -58L, -59L, -66L, -62L, -61L, -61L, -65L, -65L, -59L, -60L, -59L, -60L, -63L), WiFi4 = c(-66L, -65L, -67L, -62L, -63L, -66L, -67L, -66L, -63L, -68L, -67L, -67L, -65L, -62L, -63L, -61L, -62L, -65L, -61L, -64L), WiFi5 = c(-71L, -71L, -76L, -77L, -77L, -76L, -69L, -74L, -76L, -80L, -77L, -72L, -73L, -70L, -74L, -71L, -70L, -73L, -73L, -70L), WiFi6 = c(-82L, -85L, -85L, -90L, -81L, -88L, -87L, -87L, -86L, -86L, -83L, -86L, -84L, -85L, -89L, -86L, -84L, -83L, -84L, -84L), WiFi7 = c(-81L, -85L, -84L, -80L, -87L, -83L, -84L, -82L, -82L, -91L, -91L, -81L, -84L, -83L, -87L, -91L, -91L, -84L, -88L, -84L), Loc3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("FALSE", "TRUE"), class = "factor")), row.names = c(NA, 20L), class = "data.frame")
I got the error: Error in terms.formula(formula, data = data) : '.' in formula and no 'data' argument
What am I doing wrong?
dput(wifilocDat)
or if it is too largedput(head(wifilocDat,20))
. Also include the package you are working with in the code withlibrary(...)
. However, if you use a formula you don't need to writeTrain$Loc3~.
you can directly writeLoc3~., data=Train
– Elia