mcmodels.regressors.NadarayaWatson

class mcmodels.regressors.NadarayaWatson(kernel='linear', degree=3, coef0=1, gamma=None, kernel_params=None)[source]

NadarayaWatson Estimator.

Parameters:
kernel : string or callable, default=”linear”

Kernel mapping used to compute weights.

gamma : float, default=None

Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Ignored by other kernels.

degree : float, default=3

Degree of the polynomial kernel. Ignored by other kernels.

coef0 : float, default=1

Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.

kernel_params : mapping of string to any, optional

Additional parameters for kernel function passed as callable object.

Notes

See sklearn.kernel_ridge, for more info: Kernel Ridge Regression estimator from which the structure of this estimator is based.

Examples

>>> import numpy as np
>>> from mcmodels.regressors import NadarayaWatson
>>> # generate some fake data
>>> n_samples, n_features = 10, 5
>>> np.random.seed(0)
>>> y = np.random.randn(n_samples)
>>> X = np.random.randn(n_samples, n_features)
>>> # fit regressor
>>> reg = NadarayaWatson()
>>> reg.fit(X, y)
NadarayaWatson(coef0=1, degree=3, gamma=None, kernel='linear',
        kernel_params=None)
Attributes:
nodes

Nodes (data)

Methods

fit(self, X, y[, sample_weight]) Fit Nadaraya Watson estimator.
get_params(self[, deep]) Get parameters for this estimator.
get_weights(self, X) Return model weights.
predict(self, X) Predict using the Nadaraya Watson model.
score(self, X, y[, sample_weight]) Returns the coefficient of determination R^2 of the prediction.
set_params(self, \*\*params) Set the parameters of this estimator.
__init__(self, kernel='linear', degree=3, coef0=1, gamma=None, kernel_params=None)[source]

Methods

__init__(self[, kernel, degree, coef0, …])
fit(self, X, y[, sample_weight]) Fit Nadaraya Watson estimator.
get_params(self[, deep]) Get parameters for this estimator.
get_weights(self, X) Return model weights.
predict(self, X) Predict using the Nadaraya Watson model.
score(self, X, y[, sample_weight]) Returns the coefficient of determination R^2 of the prediction.
set_params(self, \*\*params) Set the parameters of this estimator.
fit(self, X, y, sample_weight=None)[source]

Fit Nadaraya Watson estimator.

Parameters:
X : array, shape (n_samples, n_features)

Training data.

y : array, shape (n_samples, n_features)

Target values.

Returns:
self : returns an instance of self
get_weights(self, X)[source]

Return model weights.

nodes

Nodes (data)

predict(self, X)[source]

Predict using the Nadaraya Watson model.

Parameters:
X : array, shape (n_samples, n_features)

Training data.

Returns:
C : array, shape (n_samples,) or (n_samples, n_targets)

Returns predicted values.