Skip to content

MAINT Parameters validation for sklearn.metrics.pairwise.linear_kernel #26049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sklearn/metrics/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,13 @@ def paired_distances(X, Y, *, metric="euclidean", **kwds):


# Kernels
@validate_params(
{
"X": ["array-like", "sparse matrix"],
"Y": ["array-like", "sparse matrix", None],
"dense_output": ["boolean"],
}
)
def linear_kernel(X, Y=None, dense_output=True):
"""
Compute the linear kernel between X and Y.
Expand All @@ -1193,10 +1200,10 @@ def linear_kernel(X, Y=None, dense_output=True):

Parameters
----------
X : ndarray of shape (n_samples_X, n_features)
X : {array-like, sparse matrix} of shape (n_samples_X, n_features)
A feature array.

Y : ndarray of shape (n_samples_Y, n_features), default=None
Y : {array-like, sparse matrix} of shape (n_samples_Y, n_features), default=None
An optional second feature array. If `None`, uses `Y=X`.

dense_output : bool, default=True
Expand Down
1 change: 1 addition & 0 deletions sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def _check_function_param_validation(
"sklearn.metrics.pairwise.additive_chi2_kernel",
"sklearn.metrics.pairwise.haversine_distances",
"sklearn.metrics.pairwise.laplacian_kernel",
"sklearn.metrics.pairwise.linear_kernel",
"sklearn.metrics.precision_recall_curve",
"sklearn.metrics.precision_recall_fscore_support",
"sklearn.metrics.precision_score",
Expand Down