Information Technology Reference
In-Depth Information
Training Phase:
split S to {S 1 ,S 2 ,...,S n }
results ← in parallel execution:
reduce((map predict (Model,S 1 ),map predict (Model,S 2 ),...,
map predict (Model,S 2 ))
As analyzed, we have the following script for our scenario: We first describe
the training phase implementation. The following code fragment shows the
step of extracting support vectors from a split data set StatisticEvents _ s
in the MapReduce model:
SV = FOREACH StatisticEvents_s GENERATE FLATTEN(RFuncs.svm_sv($1));
svm_sv.outputSchema ← “bag{tuple(double, double)}”;
svm_sv ← function(x) {
xDf ← as.data.frame(do.call(rbind, x[[1]]))
# data frame of training dataset
...
# extracting the support vector sv
return (list(sv))
}
The R function svm _ sv is an implementation of the map map sv function.
Extracting support vectors is the same as building an SVM model. It covers
cross validation, parameter tuning, and so on for complete SVM train-
ing. However, instead of obtaining a final SVM model, we only fetch out
the samples as support vectors after the SVM training. In our case, using a
radial-kernel-based SVM regression, SVM computation can be represented
to solve the following optimization problem:
n
n
(
)
1
2
∑∑
(
) −−
(
) +
(
)
(
)
T
2
*
*
*
*
min
αα
yy
exp
γ
xx
α αεαα
+
y
αα
ij
i
j
i
i
αα
,
*
=
1
i
=
1
i
n
(
) =
*
*
subjectto
0
αα
,
Ci
, ~
=
1
,
n
,
,
αα
0
~ .
i
i
i
i
=
1
where x i , x j are the input data set, gamma is a parameter. In R, we use the
e1071 package to supply the SVM implementation mentioned. We first use
a tuning function to find the best parameter over a parameter range, and
then we train an SVM. The following R code fragment shows the part of
extracting sv :
tuned ← tune.svm(V2 ~., data = xDf, gamma = 10^(-2:2),
kernel = 'radial') # turn the parameter
svmModel <- svm(xDf[2], xDf[1], kernel = 'radial',
gamma = tuned$best.parameters$gamma, cross = 10)
sv ← xDf[c(svmModel$index),]
sv ← apply(sv, 1, function(x){as.list(x)})
# put each row to a list
Search WWH ::




Custom Search