|
15 | 15 |
|
16 | 16 | def spectral_embedding(adjacency, k=8, mode=None):
|
17 | 17 | """ Spectral embedding: project the sample on the k first
|
18 |
| - eigen vectors of the graph laplacian. |
| 18 | + eigen vectors of the normalized graph Laplacian. |
19 | 19 |
|
20 | 20 | Parameters
|
21 | 21 | -----------
|
@@ -123,6 +123,9 @@ def spectral_clustering(adjacency, k=8, mode=None):
|
123 | 123 | ------
|
124 | 124 | The graph should contain only one connect component,
|
125 | 125 | elsewhere the results make little sens.
|
| 126 | +
|
| 127 | + This algorithm solves the normalized cut for k=2: it is a |
| 128 | + normalized spectral clustering. |
126 | 129 | """
|
127 | 130 | maps = spectral_embedding(adjacency, k=k, mode=mode)
|
128 | 131 | maps = maps[1:]
|
@@ -172,9 +175,21 @@ def fit(self, X, **params):
|
172 | 175 | -----------
|
173 | 176 | X: array-like or sparse matrix, shape: (p, p)
|
174 | 177 | The adjacency matrix of the graph to embed.
|
| 178 | + X is an adjacency matrix of a simimlarity graph: its |
| 179 | + entries must be positive or zero. Zero means that |
| 180 | + elements have nothing in comon, wereas high values mean |
| 181 | + that elements are strongly similar. |
175 | 182 |
|
176 | 183 | Notes
|
177 | 184 | ------
|
| 185 | + If you have an affinity matrix, such as a distance matrix, |
| 186 | + for which 0 means identical elements, and high values means |
| 187 | + very dissimilar elements, it can be transformed in a |
| 188 | + simimlarity matrix that is well suited for the algorithm by |
| 189 | + applying the heat kernel:: |
| 190 | +
|
| 191 | + np.exp(- X**2/2. * delta**2) |
| 192 | +
|
178 | 193 | If the pyamg package is installed, it is used. This
|
179 | 194 | greatly speeds up computation.
|
180 | 195 | """
|
|
0 commit comments