Skip to content

segfault during example(svm)

8 messages · Juergen Rose, Claudia Beleites, Peter Ehlers +1 more

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

 >
#
Am Freitag, den 18.02.2011, 11:53 -0800 schrieb Peter Ehlers:
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.
#
Dear J?rgen,

did you update.packages (checkBuilt = TRUE) ?
I recently had segfaults, too on 64bit linux (with rgl, though) and they 
disappeared only after updating with checkBuilt (including also the packages 
originally installed via Dirk's .deb packages.

HTH,

Claudia
On 02/18/2011 09:32 PM, Juergen Rose wrote:

  
    
#
On 2011-02-18 12:32, Juergen Rose wrote:
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
#
Am Freitag, den 18.02.2011, 21:42 +0100 schrieb Claudia Beleites:
Dear Claudia,

I just tried update.packages (checkBuilt = TRUE), it did not solved the
issue.

Nevertheless thanks,

Juergen
#
Dear J?rgen,
Was just a guess.
Bitte, bitte.


In case that helps tracking down the problem:
it works with my normal R as well as with r-devel. In case it helps you, I also 
put the installation protocol for r-devel below (for the normal I had it already).

Claudia


 > sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
  [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8
  [5] LC_MONETARY=C             LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8       LC_NAME=C
  [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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.13.0 Under development (unstable) (2011-02-18 r54483)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
  [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8
  [5] LC_MONETARY=C             LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=en_US.utf8       LC_NAME=C
  [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

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

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

trying URL 'http://cran.stat.unipd.it/src/contrib/e1071_1.5-24.tar.gz'
Content type 'application/octet-stream' length 312648 bytes (305 Kb)
opened URL
==================================================
downloaded 305 Kb

* installing *source* package ?e1071? ...
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
** libs
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include    -fpic  -g -O2 
-c Rsvm.c -o Rsvm.o
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include    -fpic  -g -O2 
-c cmeans.c -o cmeans.o
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include    -fpic  -g -O2 
-c cshell.c -o cshell.o
gcc -std=gnu99 -I/home/cb/r-devel/include  -I/usr/local/include    -fpic  -g -O2 
-c floyd.c -o floyd.o
g++ -I/home/cb/r-devel/include  -I/usr/local/include    -fpic  -g -O2 -c svm.cpp 
-o svm.o
svm.cpp: In function ?svm_model* svm_load_model(const char*)?:
svm.cpp:2712: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2716: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2738: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2759: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2761: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2763: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2765: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2767: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2773: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2780: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2787: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2794: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2801: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2862: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
svm.cpp:2871: warning: ignoring return value of ?int fscanf(FILE*, const char*, 
...)?, declared with attribute warn_unused_result
g++ -shared -L/usr/local/lib64 -o e1071.so Rsvm.o cmeans.o cshell.o floyd.o svm.o
installing to /home/cb/r-devel/library/e1071/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded

* DONE (e1071)

The downloaded packages are in
	?/tmp/RtmpRJM5aT/downloaded_packages?
Updating HTML index of packages in '.Library'
Making packages.html  ... done
#
Hi Peter,

Quoting Peter Ehlers <ehlers at ucalgary.ca>:
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:
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