k-medoid, ValueError: attempt to get argmin of an empty sequence
I am having numpy array below is the sample, and i want to do k-medoid clustering on it and I’m getting ValueError: attempt to get argmin of an empty sequence. This is happening according to me because some rows are having zero value. Please help. Thank you.
type: <class 'numpy.ndarray'> array([[ 1.00000000e+00, 6.15385000e+00], [ 1.30000000e+01, 3.44615000e+00], [ 1.00000000e-04, 0.00000000e+00], ..., [ 1.00000000e-04, 0.00000000e+00], [ 1.00000000e-04, 0.00000000e+00], [ 1.00000000e-04, 0.00000000e+00]])
Can you give me more details on what options like distance and number of clusters you are using? Also, is it possible to share the numpy array with me?
Hi, @surajiiitm @vmirly. I also meet this error.
File "kmedoids_tool.py", line 74, in <module>
pred_labels = KMedoids(n_clusters=10,distance='euclidean',max_iter=1000).fit
_predict(X)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyclust\_kmedoids.py", line 1
41, in fit_predict
self.fit(X)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyclust\_kmedoids.py", line 1
34, in fit
_kmedoids(X, self.n_clusters, self.distance, self.max_iter, self.n_trials, s
elf.tol, self.rng)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyclust\_kmedoids.py", line 6
2, in _kmedoids
_kmedoids_run(X, n_clusters, distance, max_iter, tol, rng)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyclust\_kmedoids.py", line 4
2, in _kmedoids_run
centers,sse_arr = _update_centers(X, membs, n_clusters, distance)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyclust\_kmedoids.py", line 2
4, in _update_centers
inx_min = np.argmin(dist)
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", l
ine 1068, in argmin
return _wrapfunc(a, 'argmin', axis=axis, out=out)
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", l
ine 52, in _wrapfunc
return getattr(obj, method)(*args, **kwds)
ValueError: attempt to get argmin of an empty sequence
pred_labels = KMedoids(n_clusters=10,distance='euclidean',max_iter=1000).fit_predict(X)
I use the euclidean distance and 10 clusters. The shape of X is (944, 1404).
Would you please help me solve this error? Thanks.