@@ -48,7 +48,9 @@ class KernelRidge(BaseEstimator, RegressorMixin):
4848 kernel : string or callable, default="linear"
4949 Kernel mapping used internally. A callable should accept two arguments
5050 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.
5254
5355 gamma : float, default=None
5456 Gamma parameter for the RBF, laplacian, polynomial, exponential chi2
@@ -73,7 +75,9 @@ class KernelRidge(BaseEstimator, RegressorMixin):
7375 Representation of weight vector(s) in kernel space
7476
7577 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].
7781
7882 References
7983 ----------
@@ -130,7 +134,9 @@ def fit(self, X, y=None, sample_weight=None):
130134 Parameters
131135 ----------
132136 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].
134140
135141 y : array-like, shape = [n_samples] or [n_samples, n_targets]
136142 Target values
@@ -173,7 +179,10 @@ def predict(self, X):
173179 Parameters
174180 ----------
175181 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.
177186
178187 Returns
179188 -------
0 commit comments