Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d431aa6

Browse filesBrowse files
MAINT Parameters validation for sklearn.metrics.pairwise.rbf_kernel (#26071)
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
1 parent 46a0156 commit d431aa6
Copy full SHA for d431aa6

File tree

Expand file treeCollapse file tree

2 files changed

+14
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-2
lines changed

‎sklearn/metrics/pairwise.py

Copy file name to clipboardExpand all lines: sklearn/metrics/pairwise.py
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,17 @@ def sigmoid_kernel(X, Y=None, gamma=None, coef0=1):
13271327
return K
13281328

13291329

1330+
@validate_params(
1331+
{
1332+
"X": ["array-like", "sparse matrix"],
1333+
"Y": ["array-like", "sparse matrix", None],
1334+
"gamma": [
1335+
Interval(Real, 0, None, closed="left"),
1336+
None,
1337+
Hidden(np.ndarray),
1338+
],
1339+
}
1340+
)
13301341
def rbf_kernel(X, Y=None, gamma=None):
13311342
"""Compute the rbf (gaussian) kernel between X and Y.
13321343
@@ -1338,10 +1349,10 @@ def rbf_kernel(X, Y=None, gamma=None):
13381349
13391350
Parameters
13401351
----------
1341-
X : ndarray of shape (n_samples_X, n_features)
1352+
X : {array-like, sparse matrix} of shape (n_samples_X, n_features)
13421353
A feature array.
13431354
1344-
Y : ndarray of shape (n_samples_Y, n_features), default=None
1355+
Y : {array-like, sparse matrix} of shape (n_samples_Y, n_features), default=None
13451356
An optional second feature array. If `None`, uses `Y=X`.
13461357
13471358
gamma : float, default=None

‎sklearn/tests/test_public_functions.py

Copy file name to clipboardExpand all lines: sklearn/tests/test_public_functions.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def _check_function_param_validation(
216216
"sklearn.metrics.pairwise.paired_euclidean_distances",
217217
"sklearn.metrics.pairwise.paired_manhattan_distances",
218218
"sklearn.metrics.pairwise.polynomial_kernel",
219+
"sklearn.metrics.pairwise.rbf_kernel",
219220
"sklearn.metrics.precision_recall_curve",
220221
"sklearn.metrics.precision_recall_fscore_support",
221222
"sklearn.metrics.precision_score",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.