8000 MAINT Parameters validation for sklearn.metrics.pairwise.sigmoid_kernel by Charlie-XIAO · Pull Request #26072 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

MAINT Parameters validation for sklearn.metrics.pairwise.sigmoid_kernel #26072

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 7 commits into from
Apr 4, 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
16 changes: 14 additions & 2 deletions sklearn/metrics/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,18 @@ def polynomial_kernel(X, Y=None, degree=3, gamma=None, coef0=1):
return K


@validate_params(
{
"X": ["array-like", "sparse matrix"],
"Y": ["array-like", "sparse matrix", None],
"gamma": [
Interval(Real, 0, None, closed="left"),
None,
Hidden(np.ndarray),
],
"coef0": [Interval(Real, None, None, closed="neither")],
}
)
def sigmoid_kernel(X, Y=None, gamma=None, coef0=1):
"""Compute the sigmoid kernel between X and Y.

Expand All @@ -1299,10 +1311,10 @@ def sigmoid_kernel(X, Y=None, gamma=None, coef0=1):

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`.

gamma : float, default=None
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 @@ -217,6 +217,7 @@ def _check_function_param_validation(
"sklearn.metrics.pairwise.paired_manhattan_distances",
"sklearn.metrics.pairwise.polynomial_kernel",
"sklearn.metrics.pairwise.rbf_kernel",
"sklearn.metrics.pairwise.sigmoid_kernel",
"sklearn.metrics.precision_recall_curve",
"sklearn.metrics.precision_recall_fscore_support",
"sklearn.metrics.precision_score",
Expand Down
0