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(...

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 3 月 28 日
編集済み: Cris LaPierre 2020 年 3 月 28 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2019b

質問済み:

2020 年 3 月 27 日

編集済み:

2020 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by