Studies / Research

Kernel Methods

By Žan Pušenjak

Machine Learning for Data Science, FRI, University of Ljubljana


machine-learning

Implementation

We implemented the kernelized ridge regression (KRR) and Support Vector Regression (SVR). To go along with the models we implemented three different kernels:

  • Polynomial kernel

  • RBF kernel

  • Linear kernel

We used the implementations on sine data. We could observe that the choice of the parameters greatly affected the fit. With SVR we had to be careful to manage the number of support vectors. We used parameters in Table1 and were able to achieve results seen on Figure6

Parameters for KRR and SVR on sine data
1-4 Model Kernel Parameters
KRR λ=1\lambda=1 ϵ=1\epsilon=1
RBF σ=0.5\sigma=0.5
KRR λ=0.001\lambda=0.001 ϵ=0.4\epsilon=0.4
Polynomial M=1M=1 c=1c=1
SVR λ=1\lambda=1
RBF σ=0.5\sigma=0.5
SVR λ=0.1\lambda=0.1
Polynomial M=1M=1 c=1c=1

Where MM is the degree of the polynomial and cc is the coefficient in the polynomial.

We observed that the RBF kernel achieved an excellent fit to the data, while the Polynomial kernel struggled to capture the underlying pattern effectively.

Fitting the housing data

We trained our model to fit the housing data. The combinations of the kernels and methods stayed the same, but this time we used nested-cross-validation (NCV) to determine the best parameter λ\lambda. We also fixed λ=1\lambda=1 and compared the two results. To determine the ϵ\epsilon parameter for SVR, we made tried to fit the model on some samples and looked at the number of the support vectors. Observing the results in 2 we can see that the parameter did not change the number so we fixed it at ϵ=0.5\epsilon = 0.5

Polynomial kernel
RBF kernel
KRR parameter exploration
Effect of ϵ\epsilon on MSE and number of support vectors
ϵ\epsilon MSE Support Vectors
0.1 26.53 12.05 95.89 28.47
0.3 26.47 12.05 91.42 28.44
0.5 26.43 12.07 96.17 24.60
0.7 26.34 12.03 98.69 25.83
0.9 26.26 12.01 101.30 23.25

Because computation of lots of parameter values was not possible we evaluated the models with a simple train-test split to get a feel for what values of parameters to explore more deeply. The results can be observed on Figure 1 for KRR and Figure 2 for SVR.

Polynomial kernel
RBF kernel
KRR parameter exploration
Polynomial kernel
RBF kernel
KRR

Thanks to this simple exploration we were able to confidently chose parameters M[1,10]M \in [1,10], σ{80,100,120}\sigma \in \{80,100,120\} and λ{0.01,0.1,1,10}\lambda \in \{0.01, 0.1, 1, 10\}. We started with leave-one-out NCV but because of computational reasons we abandoned that approach and used a 10-fold NCV.

The results can be observed on Figures 3, 4 and 5. We can see that the NCV approach outperforms the fixed λ\lambda model, and would likely perform even better if we could check even more values for λ\lambda. We can see that with polynomial kernel, the number of support vectors increases as the degree increases where with RBF kernel the sigmas do not have any effect, but the fixed lambda yields less vectors.

Performance at different parameters
Number of support vectors
SVR with Polynomial kernel
Performance at different parameters
Number of support vectors
SVR with RBF kernel
Plot of fitted regressions on sine data