[R] Using svm.plot with mlbench.spirals.
joshuacgilbert at gmail.com
Thu Jan 19 17:56:41 CET 2006
I'm trying to plot a pair of intertwined spirals and an svm that
separates them. I'm having some trouble. Here's what I tried.
Loading required package: class
> raw <- mlbench.spirals(200,2)
> spiral <- data.frame(class=as.factor(raw$classes), x=raw$x[,1], y=raw$x[,2])
> m <- svm(class~., data=spiral)
> plot(m, spiral)
Error in -x$index : invalid argument to unary operator
So we delve into e1071:::plot.svm. When I run the code in plot.svm
everything is fine up until
points(formula, data = data[-x$index, ], pch = dataSymbol,
col = symbolPalette[colind[-x$index]])
That gives me the same error message, "Error in -x$index : invalid
argument to unary operator". The weird thing is that I can run either
of the those statements in isolation
and neither gives me an error. I looked in the two points functions I
can see (points.default and points.formula) but neither calls x$index.
I was following along the documentation for plot.svm, which has a
simple example (that works)
## a simple example
m <- svm(Sex~., data = cats)
I don't see what the difference between their example and mine.
Can anyone help me?
More information about the R-help