On 2011-02-18 11:16, Juergen Rose wrote:
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.

Works just fine for me. What's your sessionInfo()?
Here's mine:
> sessionInfo()
R version 2.12.1 Patched (2010-12-27 r53883)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] e1071_1.5-24 class_7.3-3

loaded via a namespace (and not attached):
[1] tools_2.12.1


Peter Ehlers

>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to