kmedoids icon indicating copy to clipboard operation
kmedoids copied to clipboard

ValueError: attempt to get argmin of an empty sequence

Open ShanikaEdiriweera opened this issue 6 years ago • 2 comments

This error only occurs sometimes.

I think when a cluster size is zero this happens. When trying to get the min of an empty array. line 29, in kMedoids j = np.argmin(J)

Stack trace - `F:\Programs\Anaconda3\lib\site-packages\numpy\core_methods.py:59: RuntimeWarning: Mean of empty slice. warnings.warn("Mean of empty slice.", RuntimeWarning) Traceback (most recent call last):

File "", line 1, in runfile('D:/University/FYP/code/fyp_scritps/clustering/phrase_cluster.py', wdir='D:/University/FYP/code/fyp_scritps/clustering')

File "F:\Programs\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile execfile(filename, namespace)

File "F:\Programs\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/University/FYP/code/fyp_scritps/clustering/phrase_cluster.py", line 43, in M, C = kmedoids.kMedoids(D, 2)

File "D:\University\FYP\code\fyp_scritps\clustering\kmedoids\kmedoids.py", line 29, in kMedoids j = np.argmin(J)

File "F:\Programs\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 1033, in argmin return argmin(axis, out)

File "F:\Programs\Anaconda3\lib\site-packages\numpy\matrixlib\defmatrix.py", line 895, in argmin return N.ndarray.argmin(self, axis, out)._align(axis)

ValueError: attempt to get argmin of an empty sequence`

ShanikaEdiriweera avatar Aug 03 '17 04:08 ShanikaEdiriweera

i faced same issue, its because when all element assigned to other clusters, and because of that some cluster endup with 0 elements. this can be removed by reassigning cluster center randomly also output of this algo also doesn't remove cluster centers from being part of other clusters,

Pked01 avatar Nov 11 '17 15:11 Pked01

what is the tmax varaible for? and why did u set it to 100? if i have a dataset of 800 points should i put tmax=800?

TyrandeWhisperwind avatar Apr 10 '19 11:04 TyrandeWhisperwind