class sklearn.kernel_ridge.KernelRidge(alpha=1, kernel=’linear’, gamma=None, degree=3, coef0=1, kernel_params=None)
[source]
Kernel ridge regression.
Kernel ridge regression (KRR) combines ridge regression (linear least squares with l2norm regularization) with the kernel trick. It thus learns a linear function in the space induced by the respective kernel and the data. For nonlinear kernels, this corresponds to a nonlinear function in the original space.
The form of the model learned by KRR is identical to support vector regression (SVR). However, different loss functions are used: KRR uses squared error loss while support vector regression uses epsiloninsensitive loss, both combined with l2 regularization. In contrast to SVR, fitting a KRR model can be done in closedform and is typically faster for mediumsized datasets. On the other hand, the learned model is nonsparse and thus slower than SVR, which learns a sparse model for epsilon > 0, at predictiontime.
This estimator has builtin support for multivariate regression (i.e., when y is a 2darray of shape [n_samples, n_targets]).
Read more in the User Guide.
Parameters: 


Attributes: 

See also
sklearn.linear_model.Ridge
sklearn.svm.SVR
>>> from sklearn.kernel_ridge import KernelRidge >>> import numpy as np >>> n_samples, n_features = 10, 5 >>> rng = np.random.RandomState(0) >>> y = rng.randn(n_samples) >>> X = rng.randn(n_samples, n_features) >>> clf = KernelRidge(alpha=1.0) >>> clf.fit(X, y) KernelRidge(alpha=1.0, coef0=1, degree=3, gamma=None, kernel='linear', kernel_params=None)
fit (X[, y, sample_weight])  Fit Kernel Ridge regression model 
get_params ([deep])  Get parameters for this estimator. 
predict (X)  Predict using the kernel ridge model 
score (X, y[, sample_weight])  Returns the coefficient of determination R^2 of the prediction. 
set_params (**params)  Set the parameters of this estimator. 
__init__(alpha=1, kernel=’linear’, gamma=None, degree=3, coef0=1, kernel_params=None)
[source]
fit(X, y=None, sample_weight=None)
[source]
Fit Kernel Ridge regression model
Parameters: 


Returns: 

get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: 


Returns: 

predict(X)
[source]
Predict using the kernel ridge model
Parameters: 


Returns: 

score(X, y, sample_weight=None)
[source]
Returns the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1  u/v), where u is the residual sum of squares ((y_true  y_pred) ** 2).sum() and v is the total sum of squares ((y_true  y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.
Parameters: 


Returns: 

set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: 


sklearn.kernel_ridge.KernelRidge
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.kernel_ridge.KernelRidge.html