Kernel methods (SVMs, Gaussian processes, kernel ridge) compare every pair of points with a kernel. The most common is the RBF (Gaussian) kernel:
Implement rbf_kernel(X, Z, gamma=1.0) returning the (len(X), len(Z)) matrix without Python loops. Use the identity , and clip tiny negative values (from floating-point error) to 0.
Then implement kernel_ridge_predict(X_train, y_train, X_test, gamma=1.0, lam=1e-3): solve on the training data and predict .