Strange error in using kmedoids function

hi, thanks for your attention.
I'm trying to apply the kmedoids function to my dataset to cluster it into three subgroups. I set two additive parameters to the function by imposing "Algorithm" equal to "pam" and imposing a "Distance" defined by me (the Jensen – Shannon distance).
The command I run in my script is the following: kmedoids(X, 3, 'Algorithm', 'pam', 'Distance', @JSD) where X is the matrix, and JSD if the distance function difined by me. I ran the algorithm for different X data arrays and it works fine.
Only in the last run, with a new data matrix X, does it return the following error, and I don't know where the problem may be:
Error using datasample (line 123)
The value of Weights must not be complex.
Error in kmedoids>initialFunc/kplus (line 486)
[initialMedoids(ii,:), index(ii)] = datasample(S,X,1,1,'Replace',false,...
Error in internal.stats.kmedoidsPAM (line 55)
[~, medoidIndex] = initialize(X,k,S,rep);
Error in kmedoids>@(rep,S)internal.stats.kmedoidsPAM(rep,S,X,k,distObj,initialize,maxIterations,xDist,display,usePool) (line 547)
fcnHandle = @(rep,S) internal.stats.kmedoidsPAM(rep,S,X,k,distObj,initialize,maxIterations,xDist,display,usePool);
Error in internal.stats.parallel.smartForReduce (line 136)
reduce = loopbody(iter, S);
Error in kmedoids (line 411)
ClusterBest = internal.stats.parallel.smartForReduce(...

Respuestas (1)

Cris LaPierre
Cris LaPierre el 28 de Mzo. de 2020
Editada: Cris LaPierre el 28 de Mzo. de 2020
The top error is likely the one you can do something about (Error using datasample (line 123)). Is the indicated code something you wrote?
[initialMedoids(ii,:), index(ii)] = datasample(S,X,1,1,'Replace',false,...
The weights are complex, which is not allowed. Review your calculation of weights.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Etiquetas

Preguntada:

el 27 de Mzo. de 2020

Editada:

el 28 de Mzo. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by