1
$\begingroup$

I was reading this question about selecting hyper-parameters for a support vector machine classifier, where grid-search is presented as one option. Which one is correct, either

for f in folds
    for c in c_grid
        for s in sigma_grid
            # build svm
    # find best (c, s) pair (considering single-fold).
# find best (c, s) pair (considering all-folds)

or

for c in c_grid
    for s in sigma_grid
        for f in folds
            # build svm
# find best (c, s)

So does one repeat cross-validation for each (c, s) pair or does one select optimal (c, s) pair within each iteration of cross-validation?

If the first option is correct, how does one select the optimal (c,s) pair? The values could be different for different folds.

(Assume that this is the inner-loop of nested cross-validation, as per the other question.)

$\endgroup$
1
$\begingroup$

In the first one, there is no guarantee that you can find a best (c,s) pair. The best (c,s) pair might be different for every fold. Use the second one.

$\endgroup$
1
$\begingroup$

The correct alternative is the second one. What is missing is that the best (c,s) is the one that maximizes the average accuracy over the f folds.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.