fuzzyclust.viz.grid_laplacian#
- fuzzyclust.viz.grid_laplacian(grid_shape, order=2)[source]#
Regularization matrix \(\mathbf{L}=\mathbf{G}^T\mathbf{G}\) of a rectangular grid.
The prototypes \(\mathbf{v}_i\) of a fuzzy SOM sit on the nodes of a regular grid in \(s\) dimensions. Smoothness of the map is measured by finite differences of the prototypes along every grid axis: with
order=2the rows of \(\mathbf{G}\) are the second-order differences \(\mathbf{v}_{i-1}-2\mathbf{v}_i+\mathbf{v}_{i+1}\) at every interior node (Abonyi, Migály & Szeifert), withorder=1the first-order differences \(\mathbf{v}_{i+1}-\mathbf{v}_i\) of every pair of adjacent nodes (the “smoothly distributed FCM” of Pascual-Marqui et al., 2001). The penalty \(\vartheta\,\mathrm{tr}(\mathbf{V}^T\mathbf{L}\mathbf{V})\) is then \(\vartheta\sum\|\text{difference}\|^2\).- Parameters:
- Returns:
Examples
>>> from fuzzyclust.viz import grid_laplacian >>> L, pos = grid_laplacian((5,), order=2) >>> L.astype(int) array([[ 1, -2, 1, 0, 0], [-2, 5, -4, 1, 0], [ 1, -4, 6, -4, 1], [ 0, 1, -4, 5, -2], [ 0, 0, 1, -2, 1]])