using Bjontegaard metric in k-means clustering as a cost function
4 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to use Bjontegaard metric as cost fucntion in kmeans. I have some RD curve and I want to cluster them based on their slop. this means vectors that are near to each other and has near slop put in same cluster. for this I want to use Bjontegaard metric but I do not know how can I replace the cost functions with this? could you please help me how can I do this? A Matlab cod for Bjontegaard metric is also in this link:
Thank you.
0 件のコメント
回答 (1 件)
Divyam
2025 年 6 月 12 日
To use the Bjontegaard metric as a cost function in kmeans clustering, you need to build a distance matrix between all curve pairs using the Bjontegaard metric and then replace the custom distance with this matrix in the "kmedoids" function.
Here is some sample code to help you with the same:
%{
Format your curves in the below format to directly use the code below
curves = {
struct('rate', R1, 'psnr', P1),
struct('rate', R2, 'psnr', P2),
...
struct('rate', RN, 'psnr', PN)
};
%}
N = length(curves);
D = zeros(N); % Distance matrix
for i = 1:N
for j = i+1:N
try
bd = bjontegaard(curves{i}.rate, curves{i}.psnr, curves{j}.rate, curves{j}.psnr, 'rate'); % or 'dsnr'
catch
bd = inf; % in case of interpolation error
end
D(i, j) = abs(bd);
D(j, i) = D(i, j); % symmetric
end
end
k = 3; % Number of clusters
[idx, C] = kmedoids(D, k, 'Distance', 'precomputed');
Note: We are using the "kmedoids" function here since using a custom distance is not supported in the "kmeans" function.
For more information regarding the "kmedoids" function, refer to the following documentation: https://www.mathworks.com/help/stats/kmedoids.html
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!