Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81f3b63

Browse files
Ahmedbghglemaitre
andauthored
MAINT Parameters validation for spectral_clustering (#25378)
Co-authored-by: Guillaume Lemaitre <[email protected]>
1 parent 4be28d4 commit 81f3b63

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sklearn/cluster/_spectral.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from scipy.sparse import csc_matrix
1616

1717
from ..base import BaseEstimator, ClusterMixin
18-
from ..utils._param_validation import Interval, StrOptions
18+
from ..utils._param_validation import Interval, StrOptions, validate_params
1919
from ..utils import check_random_state, as_float_array
2020
from ..metrics.pairwise import pairwise_kernels, KERNEL_PARAMS
2121
from ..neighbors import kneighbors_graph, NearestNeighbors
@@ -190,6 +190,7 @@ def discretize(
190190
return labels
191191

192192

193+
@validate_params({"affinity": ["array-like", "sparse matrix"]})
193194
def spectral_clustering(
194195
affinity,
195196
*,

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def test_function_param_validation(func_module):
152152

153153
PARAM_VALIDATION_CLASS_WRAPPER_LIST = [
154154
("sklearn.cluster.affinity_propagation", "sklearn.cluster.AffinityPropagation"),
155+
("sklearn.cluster.spectral_clustering", "sklearn.cluster.SpectralClustering"),
155156
("sklearn.covariance.ledoit_wolf", "sklearn.covariance.LedoitWolf"),
156157
("sklearn.covariance.oas", "sklearn.covariance.OAS"),
157158
("sklearn.decomposition.dict_learning", "sklearn.decomposition.DictionaryLearning"),

0 commit comments

Comments
 (0)