Skip to content

Commit aa63a2d

Browse files
authored
MAINT Parameters validation for sklearn.metrics.pairwise.linear_kernel (#26049)
1 parent ac4716b commit aa63a2d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sklearn/metrics/pairwise.py

+9-2
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

+1
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)