@@ -94,8 +94,8 @@ class KMedoids(BaseEstimator, ClusterMixin, TransformerMixin):
94
94
>>> kmedoids.predict([[0,0], [4,4]])
95
95
array([0, 1])
96
96
>>> kmedoids.cluster_centers_
97
- array([[1, 2],
98
- [4, 2]])
97
+ array([[1. , 2. ],
98
+ [4. , 2. ]])
99
99
>>> kmedoids.inertia_
100
100
8.0
101
101
@@ -185,7 +185,9 @@ def fit(self, X, y=None):
185
185
random_state_ = check_random_state (self .random_state )
186
186
187
187
self ._check_init_args ()
188
- X = check_array (X , accept_sparse = ["csr" , "csc" ])
188
+ X = check_array (
189
+ X , accept_sparse = ["csr" , "csc" ], dtype = [np .float64 , np .float32 ]
190
+ )
189
191
if self .n_clusters > X .shape [0 ]:
190
192
raise ValueError (
191
193
"The number of medoids (%d) must be less "
@@ -315,7 +317,9 @@ def transform(self, X):
315
317
X_new : {array-like, sparse matrix}, shape=(n_query, n_clusters)
316
318
X transformed in the new space of distances to cluster centers.
317
319
"""
318
- X = check_array (X , accept_sparse = ["csr" , "csc" ])
320
+ X = check_array (
321
+ X , accept_sparse = ["csr" , "csc" ], dtype = [np .float64 , np .float32 ]
322
+ )
319
323
320
324
if self .metric == "precomputed" :
321
325
check_is_fitted (self , "medoid_indices_" )
@@ -345,7 +349,9 @@ def predict(self, X):
345
349
labels : array, shape = (n_query,)
346
350
Index of the cluster each sample belongs to.
347
351
"""
348
- X = check_array (X , accept_sparse = ["csr" , "csc" ])
352
+ X = check_array (
353
+ X , accept_sparse = ["csr" , "csc" ], dtype = [np .float64 , np .float32 ]
354
+ )
349
355
350
356
if self .metric == "precomputed" :
351
357
check_is_fitted (self , "medoid_indices_" )
0 commit comments