Implement pegasos_kernel_svm(data, labels, kernel='linear', lambda_val=0.01, iterations=100, sigma=1.0), a deterministic kernel Pegasos trainer for binary classification (labels in {−1,1}): every iteration visits all samples in index order, with no random sampling. Here λ = lambda_val, σ = sigma, T = iterations.
Kernels:
'linear': K(x,z)=x⋅z
'rbf': K(x,z)=exp(−∥x−z∥2/(2σ2))
Start with all αj=0 and b=0. For t=1,…,T and, inside each t, for each sample i=0,…,n−1 in order, with ηt=1/(λt):
- Compute gi=∑jαjyjK(xj,xi)+b using the current α and b (updates apply immediately to later samples).
- If yigi<1: αi←αi+ηt(1−λαi) and b←b+ηtyi.
- Otherwise: αi←αi−ηtλαi, and b is unchanged.
Return a tuple (alphas, bias): alphas is a Python list of n floats, bias a float.