[R] segfault during example(svm)

rose at uni-potsdam.de rose at uni-potsdam.de
Sat Feb 19 10:24:39 CET 2011


Hi Peter,

Quoting Peter Ehlers <ehlers at ucalgary.ca>:

> On 2011-02-18 12:32, Juergen Rose wrote:
>> Am Freitag, den 18.02.2011, 11:53 -0800 schrieb Peter Ehlers:
>>> 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
>>
>>
>>> sessionInfo()
>> R version 2.12.1 (2010-12-16)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>> locale:
>>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods
>> base
>>
>> It is working at some of my systems and is failing at the most.
>>
>
> It would be good to know what version of e1071 you're using;
> presumably it's 1.5-24. I've run the example on both 32-bit
> and 64-bit R 12.2.1pat and 2.13.0dev with no problems.
> Could you be having a problem with your graphics device?
>
> Peter Ehlers

I now have not acces to the computer, where the error happens first  
time On an other computer where the same issue occurs sessionInfo says:

> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)
...
other attached packages:
[1] e1071_1.5-24 class_7.3-3



More information about the R-help mailing list