Sutton & Barto describe two faces of kernels in value-function approximation: kernel regression, a memory-based method that answers a query with a kernel-weighted average of stored targets, and the observation that every linear parametric method is kernel regression with the kernel .
Write three functions. All return 1-D numpy arrays of predictions, one per query row.
kernel_regression(D_states, D_targets, queries, sigma): Gaussian RBF kernel regression. For each query , weight every stored example by and return the weighted average of the stored targets (weights normalised to sum to 1). States are rows of 2-D arrays, or scalars in 1-D arrays.
linear_ridge_predict(X_train, y_train, X_query, lam): the parametric method. Find the weights minimising and return .
kernel_ridge_predict(K_train, y_train, K_query, lam): the same predictor written only in terms of kernel values. K_train is the matrix over training states and K_query is the matrix . Return the predictions .
With the last two functions must agree.