Borrar filtros
Borrar filtros

Hierarchical clustering with similarity matrix

27 visualizaciones (últimos 30 días)
Emanuele Giacomuzzo
Emanuele Giacomuzzo el 4 de En. de 2021
Editada: Umar el 9 de Ag. de 2024
Hi there,
I have a similarity matrix that I would like to use as the input of the function linkage. However, this takes as an input only the a dissimilarity/distance matrix. Do you know any way by which I can manage to run a hierarchical clustering in Matlab using my similarity matrix?
Cheers!

Respuestas (1)

Akanksha Shrimal
Akanksha Shrimal el 26 de Abr. de 2022
Hi,
It is my understanding that you want to compute Hierarchical Clustering with ‘linkage’ function in MATLAB using a similarity matrix.
The ‘linkage’ function in MATLAB takes input as distance vector to compute clusters.
Given a similarity matrix s, we can compute the dissimilarity matrix of s by
ds = 1 s
This dissimilarity matrix is then converted into a vector form that 'linkage' accepts using 'squareform'.
X = squareform(ds)
Now you can apply 'linkage' with X using ‘complete’ method for calculating distance between clusters.
Z = linkage(X,complete)
For more details refer to this documentation link.
Hope this helps.
  1 comentario
Umar
Umar el 9 de Ag. de 2024
Editada: Umar el 9 de Ag. de 2024

Hi @Akanksha Shrimal,

I executed the code above following your mentioned instructions,”Given a similarity matrix s, we can compute the dissimilarity matrix of s by

ds = 1 – s

This dissimilarity matrix is then converted into a vector form that 'linkage' accepts using 'squareform'.

X = squareform(ds) “

and encountered an error in code. Please see attached.

Am I missing something?

The definition of similarity matrix can be found here,

https://www.mathworks.com/help/stats/spectralcluster.html#mw_319da951-f871-482c-b648-5056f4ebff46_sep_shared-SimilarityMatrix

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by