Spectral clustering is a graph-based clustering technique that identifies clusters by following three key steps: (1) Pre-processing: Construct the Laplacian matrix representation of the graph; (2) Eigenvalue decomposition: Compute the eigenvalues and eigenvectors of the Laplacian matrix, focusing on the second smallest eigenvalue (λ₂) and its corresponding eigenvector; (3) Grouping: Sort the components of the eigenvector and split them into positive and negative values to assign nodes to different clusters. For multiple clusters, either recursively partition the graph or use multiple eigenvectors to create coordinate representations for each node before applying k-means clustering.
Spectral Clustering: Three Steps to Graph Partitioning | Stanford Lecture 34
Added:So basically let me quickly summarize what we have uh learned so far right. So if you want to apply spectral graph partitioning to find two clusters uh in a given graph there are three steps we have to go through. In the first step we have to do what is called pre-processing where we construct a matrix representation of a graph.
In the second step we go and compute the igen value decomposition of this of this graph by identifying igon values and igon vectors. In particular, we are interested in the second smallest igon value lambda 2 and the corresponding igon vector x. And then once we have the the the vector x, all we have to do is we have to go and do the grouping where we basically look at the components and of x and determine which nodes belong to the set a and which nodes belong to the set b. Right? Kind of who belongs to the left partition, who belongs to the right partition. So let me now give you an example. Right? So in the pre-processing step I take our graph G and compute the lelassian matrix L. In the second step then we do the igen value de composition where basically we take our L when we find a set of igon values and a set of igon vectors to this matrix L. We take the um second uh smallest igon value and the corresponding igon vector. Here it is right. We take this this one out. So here are now all the nodes one to one to six and these are the corresponding um um entries of the iggon vector and what we find for example is that now what we have to do is we have to group these nodes right we would like to group these nodes into two clusters corresponding to the embedding or the labels of the nodes that that we have in the corresponding vector. So how do we do this grouping? Um doing the grouping is very simple. we basically go and sort the components of uh of this of vector x and identify clusters by splitting the vector in two. So a naive approach to this to this case would be to ask what are the corresponding values that are negative what are the corresponding values that are positive.
Right? So if this is our vector x, we would split it here between nodes three and four. These are all the nodes that are on the right hand side of the zero.
These are all the nodes on the left hand side of the zero. Notice that sum of the node labels equals to zero exactly as we said we said it should be.
Also notice the sum of the squares of the values equals to one which is again exactly as it should be. So what this basically means is now by splitting this vector in in half into kind of the positive part and the negative part. We identified the two clusters. Here is the cluster A which is composed of nodes one to three and the cluster B that is composed of nodes four five and six. So I have an A and I have a B. Right? So basically what the components of second smallest vector did it basically embedded the nodes on a line assigned them positive and negative values. We take all the positive nodes put them into cluster A.
Take all the negative nodes nodes with negative values put them in the cluster B. So now if I give you a bit uh more interesting example here I have graph on the left G that you see it has two clusters. Um I computed the graph lelassian I computed the lambda 2 and the corresponding igon vector x. Um and all I did here is now I sorted the vector x2 right the corresponding igon vector to the second smallest value by by um by the entries. And what you see very nicely is there is a set of components that has a negative value and a set of components that has a positive value. So basically uh the igen values or the entries of the igen vector with a positive value correspond to one cluster um and the remaining ones correspond to the second cluster. Of course you can now start asking what is there anything interesting about the igen vectors that correspond to let's say the third smallest igen value the fourth smallest igen value and so on. And just to for example show you what happens that um the first case I'll show you is a graph that I have here that actually contains four small clusters. If the graph contains four small clusters and I still compute um lambda 2 and the corresponding igon vector x2 what I show you here is now the the components of this igon vector. And you see how how the entries now first are split into two clusters right kind of above zero and below zero. But then you actually find that here we have these different steps right. So basically we have the first the two clusters and then each of the two clusters has two small clusters embedded in them. And we see this kind of from the structure of the components of the second vector very nicely. So the question is if I have multiple um clusters how would I go identify them?
So let me just show you um some examples how to do this. For example, if this is my graph G, the same as I had before, I have my lelassian matrix L that I do on de composition. For example, here are the components of vector X1 and they all have exactly the same value. So exactly as as as we said and as we have proven but for example the components of the third um smallest vector are the following. And now what you see here is for example that this is the the bottom cluster. This is the the second cluster.
then this would be the third cluster and here these components correspond to the uh fourth cluster. So basically what does this mean? This gives us now an idea of how do we go if you want to partition a graph not in two clusters but in k of them. There are two possible approaches.
One approach is to do recursive by partitioning. It's basically take the full graph, split it in two and now for each of the two pieces again kind of try to split it in two and we keep applying this recursively in until we are getting kind of smaller and smaller pieces. And another idea is to basically cluster using multiple igon values and multiple igon vectors. So basically the idea is that for every node in the graph we take our lelassian matrix compute the igen value de composition and now we take the second igon vector the third igon vector fourth igon vector which basically means that every node of the graph is now um uh described by a small vector of values and now we can apply kins or something like that to um to identify the clusters. So basically the idea would be that we take the graph compute the lelassian matrix from lelassian matrix what we will do is for every node I we will come up with its corresponding in some sense coordinates right so we will take the uh co coordinate i of second smallest igon vector coordinate i of the third smallest igon vector and so on and so forth. And now that every node is described by a set of coordinates, we can run kins that we have already discussed how to use uh to identify k clusters. And it turns out that in practice this method uh works really well. So with this we have finished the discussion of spectral clustering and basically given a graph how to find individual clusters of nodes uh in it.
Up Next

Spectral Clustering Explained: Theory & Key Steps
@OmarSobhUSA
86.9K views•2015-08-26

Building Real-Time ML Pipelines with Feature Stores and MLOps Frameworks
@ODSCAI
5.1K views•2022-02-20

Bypassing Tor Censorship: Bridges and Pluggable Transport Guide
@Coding_ForEveryone
397 views•2024-06-11

Neural Networks Explained: Math, Layers, and Learning Fundamentals
@3blue1brown
21.9M views•2017-10-05
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Artificial Intelligence













![▶️ [REPLAY] - La carte de l'IA | Partie 1](https://i.ytimg.com/vi/mT6NnslbNLM/maxresdefault.jpg)





















