Skip to content

[source]

Mean Shift#

A hierarchical clustering algorithm that uses peak (maxima) finding to locate the candidate centroids of a training set given a radius constraint. Near-duplicate centroids are merged together and the algorithm iterates on the remaining candidates in subsequent steps until the centroids stabilize.

Interfaces: Estimator, Learner, Probabilistic, Verbose, Persistable

Data Type Compatibility: Continuous

Parameters#

# Name Default Type Description
1 radius float The bandwidth of the radial basis function.
2 ratio 0.1 float The ratio of samples from the training set to use as initial centroids.
3 epochs 100 int The maximum number of training rounds to execute.
4 minShift 1e-4 float The minimum mean per-column displacement of the remaining centroids necessary to continue training.
5 tree BallTree Spatial The spatial tree used to run range searches.
6 seeder Random Seeder The seeder used to initialize the cluster centroids.

Example#

use Rubix\ML\Clusterers\MeanShift;
use Rubix\ML\Graph\Trees\BallTree;
use Rubix\ML\Clusterers\Seeders\KMC2;

$estimator = new MeanShift(2.5, 0.05, 2000, 1e-6, new BallTree(100), new KMC2());

Additional Methods#

Estimate the radius of a cluster that encompasses a certain percentage of the total training samples.

public static estimateRadius(Dataset $dataset, float $percentile = 30.0, ?Distance $kernel = null) : float

Note

Since radius estimation scales quadratically in the number of samples, for large datasets you can speed up the process by running it on a smaller subset of the training data.

Return the centroids computed from the training set.

public centroids() : array[]

Returns the amount of centroid shift during each epoch of training. The shift of an epoch is the total per-column displacement of the centroids that survived the merge step from the positions they were shifted from, divided by the number of training samples. Centroids that were pruned are not counted.

public losses() : float[]|null

Return the progress table combining every epoch recorded during the last training session — the centroid shift at each epoch — into a single ordered sequence.

public progress() : iterable

Return the base spatial tree instance.

public tree() : Spatial

References#


  1. M. A. Carreira-Perpinan et al. (2015). A Review of Mean-shift Algorithms for Clustering. ↩

  2. D. Comaniciu et al. (2012). Mean Shift: A Robust Approach Toward Feature Space Analysis. ↩