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

3 visualizaciones (últimos 30 días)
nadia naji
nadia naji el 13 de Jun. de 2022
Respondida: Divyam el 12 de Jun. de 2025
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.

Respuestas (1)

Divyam
Divyam el 12 de Jun. de 2025
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

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by