[R] segfault during example(svm)

Juergen Rose rose at rz.uni-potsdam.de
Fri Feb 18 20:16:46 CET 2011


If do:
> library("e1071")
> example(svm)

I get:


svm> data(iris)

svm> attach(iris)

svm> ## classification mode
svm> # default with factor response:
svm> model <- svm(Species ~ ., data = iris)

svm> # alternatively the traditional interface:
svm> x <- subset(iris, select = -Species)

svm> y <- Species

svm> model <- svm(x, y) 

svm> print(model)

Call:
svm.default(x = x, y = y)


Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  radial 
       cost:  1 
      gamma:  0.25 

Number of Support Vectors:  51


svm> summary(model)

Call:
svm.default(x = x, y = y)


Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  radial 
       cost:  1 
      gamma:  0.25 

Number of Support Vectors:  51

 ( 8 22 21 )


Number of Classes:  3 

Levels: 
 setosa versicolor virginica




svm> # test with train data
svm> pred <- predict(model, x)

svm> # (same as:)
svm> pred <- fitted(model)

svm> # Check accuracy:
svm> table(pred, y)
            y
pred         setosa versicolor virginica
  setosa         50          0         0
  versicolor      0         48         2
  virginica       0          2        48

svm> # compute decision values and probabilities:
svm> pred <- predict(model, x, decision.values = TRUE)

svm> attr(pred, "decision.values")[1:4,]
  setosa/versicolor setosa/virginica versicolor/virginica
1          1.196152         1.091460            0.6705626
2          1.064621         1.056332            0.8479934
3          1.180842         1.074534            0.6436474
4          1.110699         1.053143            0.6778595

svm> # visualize (classes by color, SV by crosses):
svm> plot(cmdscale(dist(iris[,-5])),
svm+      col = as.integer(iris[,5]),
svm+      pch = c("o","+")[1:150 %in% model$index + 1])

 *** caught segfault ***
address (nil), cause 'unknown'

Traceback:
 1: .Call("La_rs", x, only.values, PACKAGE = "base")
 2: eigen(-x/2, symmetric = TRUE)
 3: cmdscale(dist(iris[, -5]))
 4: plot(cmdscale(dist(iris[, -5])), col = as.integer(iris[, 5]),
pch = c("o", "+")[1:150 %in% model$index + 1])
 5: eval.with.vis(expr, envir, enclos)
 6: eval.with.vis(ei, envir)
 7: source(tf, local, echo = echo, prompt.echo = paste(prompt.prefix,
getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix,
getOption("continue"), sep = ""), verbose = verbose, max.deparse.length
= Inf,     encoding = "UTF-8", skip.echo = skips, keep.source = TRUE)
 8: example(svm)

Possible actions:
1: abort (with core dump, if enabled)
..

I did already "update.packages(), what can I still do.



More information about the R-help mailing list