KernelRegression
¶
-
class
numpy_ml.nonparametric.
KernelRegression
(kernel=None)[source]¶ A Nadaraya-Watson kernel regression model.
Notes
The Nadaraya-Watson regression model is
\[f(x) = \sum_i w_i(x) y_i\]where the sample weighting functions, \(w_i\), are simply
\[w_i(x) = \frac{k(x, x_i)}{\sum_j k(x, x_j)}\]with k being the kernel function.
Observe that k-nearest neighbors (
KNN
) regression is a special case of kernel regression where the k closest observations have a weight 1/k, and all others have weight 0.Parameters: kernel (str, Kernel object, or dict) – The kernel to use. If None, default to LinearKernel
. Default is None.