@@ -48,7 +48,9 @@ class KernelRidge(BaseEstimator, RegressorMixin):
48
48
kernel : string or callable, default="linear"
49
49
Kernel mapping used internally. A callable should accept two arguments
50
50
and the keyword arguments passed to this object as kernel_params, and
51
- should return a floating point number.
51
+ should return a floating point number. Set to "precomputed" in
52
+ order to pass a precomputed kernel matrix to the estimator
53
+ methods instead of samples.
52
54
53
55
gamma : float, default=None
54
56
Gamma parameter for the RBF, laplacian, polynomial, exponential chi2
@@ -73,7 +75,9 @@ class KernelRidge(BaseEstimator, RegressorMixin):
73
75
Representation of weight vector(s) in kernel space
74
76
75
77
X_fit_ : {array-like, sparse matrix}, shape = [n_samples, n_features]
76
- Training data, which is also required for prediction
78
+ Training data, which is also required for prediction. If
79
+ kernel == "precomputed" this is instead the precomputed
80
+ training matrix, shape = [n_samples, n_samples].
77
81
78
82
References
79
83
----------
@@ -130,7 +134,9 @@ def fit(self, X, y=None, sample_weight=None):
130
134
Parameters
131
135
----------
132
136
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
133
- Training data
137
+ Training data. If kernel == "precomputed" this is instead
138
+ a precomputed kernel matrix, shape = [n_samples,
139
+ n_samples].
134
140
135
141
y : array-like, shape = [n_samples] or [n_samples, n_targets]
136
142
Target values
@@ -173,7 +179,10 @@ def predict(self, X):
173
179
Parameters
174
180
----------
175
181
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
176
- Samples.
182
+ Samples. If kernel == "precomputed" this is instead a
183
+ precomputed kernel matrix, shape = [n_samples,
184
+ n_samples_fitted], where n_samples_fitted is the number of
185
+ samples used in the fitting for this estimator.
177
186
178
187
Returns
179
188
-------
0 commit comments