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: _DensityPeaks

Mountain 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 as grid_size ** n_features.

Parameters:
grid_sizeint or None, default=None

Number of grid nodes per feature (the grid spans the data range). None chooses the largest value whose total number of nodes grid_size ** n_features does not exceed max_nodes (at least two per feature).

max_nodesint, default=10000

Upper bound on the total number of grid nodes; an explicit grid_size that exceeds it raises an error. The bound makes the exponential cost of the grid explicit.

radiifloat or array_like of shape (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.

squashfloat, default=1.25

Ratio \(r_b/r_a\) of the destruction radius to the influence radius, \(\beta=4/r_b^2\).

stop_ratiofloat, default=0.15

The procedure stops when the highest remaining mountain falls below this fraction of the first peak \(M^*_1\).

max_clustersint or None, default=None

Upper bound on the number of centers.

Attributes:
cluster_centers_ndarray of shape (n_clusters_, n_features)

The selected grid nodes, in the original units.

n_clusters_int
grid_ndarray of shape (grid_size_ ** n_features, n_features)

The grid nodes (original units).

grid_size_int

Number of nodes per feature actually used.

mountain_ndarray of shape (grid_size_ ** n_features,)

Mountain function on the grid before any destruction.

potentials_ndarray of shape (n_clusters_,)

Peak heights \(M^*_i/M^*_1\) at selection.

membership_, labels_, radii_

As in SubtractiveClustering.

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 of shape (n_samples, n_features)
yIgnored
Returns:
selfobject

Examples using fuzzyclust.cluster.MountainClustering#

Subtractive clustering: the number and location of clusters from density

Subtractive clustering: the number and location of clusters from density