fuzzyclust.cluster.MountainClustering#
- class fuzzyclust.cluster.MountainClustering(grid_size=None, max_nodes=10000, radii=0.5, squash=1.25, stop_ratio=0.15, max_clusters=None)[source]#
Bases:
_DensityPeaksMountain method (Yager & Filev, 1994): cluster centers from a mountain function on a grid.
A grid is laid over the data space and at every grid node the mountain function—the sum of Gaussian influences of all data points—is evaluated. The node of the highest mountain is the first center; its mountain is subtracted from all nodes (the destruction of the mountain) and the next peak is selected, until the remaining peak is a small fraction of the first. Subtractive clustering (
SubtractiveClustering) replaces the grid by the data points themselves; the mountain method is kept for its didactic value and for low-dimensional problems, since the number of nodes grows asgrid_size ** n_features.- Parameters:
- grid_size
intorNone, default=None Number of grid nodes per feature (the grid spans the data range).
Nonechooses the largest value whose total number of nodesgrid_size ** n_featuresdoes not exceedmax_nodes(at least two per feature).- max_nodes
int, default=10000 Upper bound on the total number of grid nodes; an explicit
grid_sizethat exceeds it raises an error. The bound makes the exponential cost of the grid explicit.- radii
floator array_likeofshape(n_features,), default=0.5 Width of the Gaussian influence as a fraction of the feature range; \(\alpha=4/r_a^2\) in the unit hypercube.
- squash
float, default=1.25 Ratio \(r_b/r_a\) of the destruction radius to the influence radius, \(\beta=4/r_b^2\).
- stop_ratio
float, default=0.15 The procedure stops when the highest remaining mountain falls below this fraction of the first peak \(M^*_1\).
- max_clusters
intorNone, default=None Upper bound on the number of centers.
- grid_size
- Attributes:
- cluster_centers_
ndarrayofshape(n_clusters_,n_features) The selected grid nodes, in the original units.
- n_clusters_
int - grid_
ndarrayofshape(grid_size_**n_features,n_features) The grid nodes (original units).
- grid_size_
int Number of nodes per feature actually used.
- mountain_
ndarrayofshape(grid_size_** n_features,) Mountain function on the grid before any destruction.
- potentials_
ndarrayofshape(n_clusters_,) Peak heights \(M^*_i/M^*_1\) at selection.
- membership_, labels_, radii_
As in
SubtractiveClustering.
- cluster_centers_
Notes
With the data and the grid nodes \(\mathbf{N}_i\) scaled to the unit hypercube,
\[M(\mathbf{N}_i)=\sum_{k=1}^{N}\exp\bigl(-\alpha\|\mathbf{N}_i-\mathbf{x}_k\|^2\bigr),\qquad M(\mathbf{N}_i)\leftarrow M(\mathbf{N}_i)-M^*_j\exp\bigl(-\beta\|\mathbf{N}_i-\mathbf{N}^*_j\|^2\bigr),\]where Yager and Filev’s constants \(\alpha\) and \(\beta\) are expressed through the radii as \(\alpha=4/r_a^2\), \(\beta=4/r_b^2\).
References
[1]R. R. Yager, D. P. Filev, “Approximate clustering via the mountain method”, IEEE Transactions on Systems, Man, and Cybernetics 24(8), 1279–1284, 1994.
Examples
>>> from fuzzyclust.cluster import MountainClustering >>> from fuzzyclust.datasets import make_fuzzy_blobs >>> X, _ = make_fuzzy_blobs(n_clusters=3, random_state=0) >>> mc = MountainClustering(grid_size=15, radii=0.3).fit(X) >>> int(mc.n_clusters_), mc.grid_.shape (3, (225, 2)) >>> MountainClustering(radii=0.3).fit(X).grid_size_ # automatic: 100 x 100 nodes 100
- fit(X, y=None)[source]#
Estimate the cluster centers on the grid.
- Parameters:
- Xarray_like
ofshape(n_samples,n_features) - y
Ignored
- Xarray_like
- Returns:
- self
object
- self
Examples using fuzzyclust.cluster.MountainClustering#
Subtractive clustering: the number and location of clusters from density