@@ -2575,17 +2575,23 @@ def pairwise_kernels(
2575
2575
):
2576
2576
"""Compute the kernel between arrays X and optional array Y.
2577
2577
2578
- This method takes either a vector array or a kernel matrix, and returns
2579
- a kernel matrix. If the input is a vector array, the kernels are
2580
- computed. If the input is a kernel matrix, it is returned instead.
2578
+ This method takes one or two vector arrays or a kernel matrix, and returns
2579
+ a kernel matrix.
2580
+
2581
+ - If `X` is a vector array, of shape (n_samples_X, n_features), and:
2582
+
2583
+ - `Y` is `None` and `metric` is not 'precomputed', the pairwise kernels
2584
+ between `X` and itself are computed.
2585
+ - `Y` is a vector array of shape (n_samples_Y, n_features), the pairwise
2586
+ kernels between arrays `X` and `Y` is returned.
2587
+
2588
+ - If `X` is a kernel matrix, of shape (n_samples_X, n_samples_X), `metric`
2589
+ should be 'precomputed'. `Y` is thus ignored and `X` is returned as is.
2581
2590
2582
2591
This method provides a safe way to take a kernel matrix as input, while
2583
2592
preserving compatibility with many other algorithms that take a vector
2584
2593
array.
2585
2594
2586
- If Y is given (default is None), then the returned matrix is the pairwise
2587
- kernel between the arrays from both X and Y.
2588
-
2589
2595
Valid values for metric are:
2590
2596
['additive_chi2', 'chi2', 'linear', 'poly', 'polynomial', 'rbf',
2591
2597
'laplacian', 'sigmoid', 'cosine']
0 commit comments