[R] question about svm(e1071)

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Jan 14 19:09:32 CET 2011


Looking at your results suggests that differences are probably based on 
expected minor numerical inaccuracies and the possibly alternating sign 
of the support vectors.

Best,
Uwe Ligges



On 13.01.2011 01:28, mutohrn at chugai-pharm.co.jp wrote:
> Dear all,
>
> I executed svm calculation using e1071 library with a microarray data (http://www.iu.a.u-tokyo.ac.jp/~kadota/R/data_Singh_RMA_3274.txt).
> Then, I shuffled the data samples and executed svm calculation again.
> The results of 2 calculation were different (in SV, coefs and weights).
>
> I attached the script below. Could please tell me why this happens?
> If possible please tell me how to make them equal.
>
> Best regards,
>
> Hiro
>
> ### Script start ###
>
> library(e1071)
> data<- read.table('http://www.iu.a.u-tokyo.ac.jp/~kadota/R/data_Singh_RMA_3274.txt', header=TRUE, row.names=1, sep="\t", quote="")
>
> data.cl<- rep(NA,ncol(data))
> data.cl[grep('Normal',colnames(data))]<- 'Normal'
> data.cl[grep('Tumour',colnames(data))]<- 'Tumour'
>
> s<- sample(ncol(data))
>
> m<- svm(x=t(data    ), y=factor(data.cl   ), scale=T, type="C-classification",kernel="linear")
> m.s<- svm(x=t(data[,s]), y=factor(data.cl[s]), scale=T, type="C-classification", kernel="linear")
>
> w<- t(m  $coefs) %*% m$SV
> w.s<- t(m.s$coefs) %*% m.s$SV
>
> # SV and coefs are slightly different
> sum(abs(m$SV[order(rownames(m$SV)),] - m.s$SV[order(rownames(m.s$SV)),]))
> sum(abs(m$coefs[order(rownames(m$SV))] -m.s$coefs[order(rownames(m.s$SV))]))
>
> # rank of weight are not identical
> all(rank(w)==rank(w.s))
>
> ### Script end ###
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list