custom distance with the kmeans

2 ビュー (過去 30 日間)
majeed
majeed 2022 年 11 月 7 日
コメント済み: majeed 2022 年 11 月 8 日
hi ,
i wanna use this equation to comput distance detween each data and two centroid ( let data (x1,x2) and first centroid (c1,c2) and second centroid (c3,c4)
abs((x1-c1)/std(x1))+abs((x2-c2)/std(x1)) this between the data and first centroid
abs((x1-c3)/std(x2))+abs((x2-c4)/std(x2)) this between the data and second centroid
then choice the shortest ( this in kmeans function )
thanks

回答 (1 件)

David Hill
David Hill 2022 年 11 月 7 日
data=randi(100,10,2);
centroid1=randi(100,1,2);
centroid2=randi(100,1,2);
m=sum(abs((data-centroid1)./std(data(:,1))),2);
n=sum(abs((data-centroid2)./std(data(:,2))),2);
km=min(m,n)
km = 10×1
0.5618 2.5094 0.7151 0.1873 1.0936 2.3971 2.4720 1.6854 1.5731 1.2619
  3 件のコメント
David Hill
David Hill 2022 年 11 月 7 日
I am not sure what you want. Are you having problems using kmeans? Have you looked at the matlab documentation kmeans?
majeed
majeed 2022 年 11 月 8 日
i wanna use kmeans but use special equation to comput distance

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by