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.

回答(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