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 31bee41

Browse filesBrowse files
Charlie-XIAOItay
authored and
Itay
committed
MAINT Parameters validation for sklearn.metrics.pairwise.linear_kernel (scikit-learn#26049)
1 parent ab1f0a1 commit 31bee41
Copy full SHA for 31bee41

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+10
-2
lines changed

‎sklearn/metrics/pairwise.py

Copy file name to clipboardExpand all lines: sklearn/metrics/pairwise.py
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,13 @@ def paired_distances(X, Y, *, metric="euclidean", **kwds):
11851185

11861186

11871187
# Kernels
1188+
@validate_params(
1189+
{
1190+
"X": ["array-like", "sparse matrix"],
1191+
"Y": ["array-like", "sparse matrix", None],
1192+
"dense_output": ["boolean"],
1193+
}
1194+
)
11881195
def linear_kernel(X, Y=None, dense_output=True):
11891196
"""
11901197
Compute the linear kernel between X and Y.
@@ -1193,10 +1200,10 @@ def linear_kernel(X, Y=None, dense_output=True):
11931200
11941201
Parameters
11951202
----------
1196-
X : ndarray of shape (n_samples_X, n_features)
1203+
X : {array-like, sparse matrix} of shape (n_samples_X, n_features)
11971204
A feature array.
11981205
1199-
Y : ndarray of shape (n_samples_Y, n_features), default=None
1206+
Y : {array-like, sparse matrix} of shape (n_samples_Y, n_features), default=None
12001207
An optional second feature array. If `None`, uses `Y=X`.
12011208
12021209
dense_output : bool, default=True

‎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
@@ -203,6 +203,7 @@ def _check_function_param_validation(
203203
"sklearn.metrics.pairwise.additive_chi2_kernel",
204204
"sklearn.metrics.pairwise.haversine_distances",
205205
"sklearn.metrics.pairwise.laplacian_kernel",
206+
"sklearn.metrics.pairwise.linear_kernel",
206207
"sklearn.metrics.precision_recall_curve",
207208
"sklearn.metrics.precision_recall_fscore_support",
208209
"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.