using Bjontegaard metric in k-means clustering as a cost function

조회 수: 1 (최근 30일)
nadia naji
nadia naji 2022년 6월 13일
답변: Divyam 2025년 6월 12일
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.

답변 (1개)

Divyam
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

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by