[R] SVM Param Tuning with using SNOW package
raluca
ucagui at hotmail.com
Wed Nov 18 00:01:13 CET 2009
Hello,
Is the first time I am using SNOW package and I am trying to tune the cost
parameter for a linear SVM, where the cost (variable cost1) takes 10 values
between 0.5 and 30.
I have a large dataset and a pc which is not very powerful, so I need to
tune the parameters using both CPUs of the pc.
Somehow I cannot manage to do it. It seems that both CPUs are fitting the
model for the same values of cost1, I guess the first 5, but not for the
last 5.
Please, can anyone help me! :-((
Here is the code:
data <- data.frame(Y=I(Y),X=I(X))
data.X<-data$X
data.Y<-data$Y
NR=10
cost1=seq(0.5,30, length=NR)
sv.lin<- function(cl,c) {
for (i in 1:NR) {
ind=sample(1:414,276)
hogTest<- data.frame(Y=I(data.Y[-ind]),X=I(data.X[-ind,]))
hogTrain<- data.frame(Y=I(data.Y[ind]),X=I(data.X[ind,]))
svm.lin <- svm(hogTrain$X,hogTrain$Y, kernel="linear",cost=c[i],
cross=5)
results.lin <- predict(svm.lin, hogTest$X)
e.test.lin <- sqrt(sum((results.lin-hogTest$Y)^2)/length(hogTest$Y))
return(e.test.lin)
}
}
cl<- makeCluster(10, type="SOCK" )
clusterEvalQ(cl,library(e1071))
clusterExport(cl,c("data.X","data.Y","NR","cost1"))
RMSEP<-clusterApplyLB(cl,cost1,sv.lin)
stopCluster(cl)
--
View this message in context: http://old.nabble.com/SVM-Param-Tuning-with-using-SNOW-package-tp26399401p26399401.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list