Strange error in using kmedoids function

조회 수: 3 (최근 30일)
Alessandro Fuschi
Alessandro Fuschi 2020년 3월 27일
편집: Cris LaPierre 2020년 3월 28일
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(...

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 3월 28일
편집: Cris LaPierre 2020년 3월 28일
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.

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by