setup_LinearSVM() and setup_RadialSVM() fit support vector machines with a linear and a radial basis function kernel, using e1071::svm(). The backend standardizes the features, and for regression the outcome, before fitting; rtemis one-hot encodes factors. This chapter fits support vector regression to the diabetes data, examines the effects of \(C\) and \(\gamma\), and tunes them jointly.
With a linear kernel, support vector regression fits a linear function with the \(\varepsilon\)-insensitive loss and a ridge penalty, and its performance is close to that of the least squares fit for every value of \(C\) examined.
27.2 Radial basis function kernel
The RBF kernel adds the width \(\gamma\). A grid of values shows how the two hyperparameters interact:
Large \(\gamma\) and large \(C\) together produce the most flexible fit: at \(\gamma\) = 0.1 and \(C\) = 100, the training \(R^2\) is 0.960 and the test \(R^2\) -0.350. The best combination in this grid, \(\gamma\) = 0.01 and \(C\) = 1, has a test \(R^2\) of 0.505. The choice of the best cell from this table uses the outer test folds, so its value is optimistic (Section 20.3); nested tuning gives an estimate free of this selection.
The nested estimate of the tuned RBF support vector regression is a mean test \(R^2\) of 0.504, comparable to the linear and additive models of the previous chapters on these data.