mlpack
|
This class implements mean shift clustering. More...
#include <mean_shift.hpp>
Public Member Functions | |
MeanShift (const double radius=0, const size_t maxIterations=1000, const KernelType kernel=KernelType()) | |
Create a mean shift object and set the parameters which mean shift will be run with. More... | |
double | EstimateRadius (const MatType &data, const double ratio=0.2) |
Give an estimation of radius based on given dataset. More... | |
void | Cluster (const MatType &data, arma::Row< size_t > &assignments, arma::mat ¢roids, bool forceConvergence=true, bool useSeeds=true) |
Perform mean shift clustering on the data, returning a list of cluster assignments and centroids. More... | |
size_t | MaxIterations () const |
Get the maximum number of iterations. | |
size_t & | MaxIterations () |
Set the maximum number of iterations. | |
double | Radius () const |
Get the radius. | |
void | Radius (double radius) |
Set the radius. | |
const KernelType & | Kernel () const |
Get the kernel. | |
KernelType & | Kernel () |
Modify the kernel. | |
This class implements mean shift clustering.
For each point in dataset, apply mean shift algorithm until maximum iterations or convergence. Then remove duplicate centroids.
A simple example of how to run mean shift clustering is shown below.
UseKernel | Use kernel or mean to calculate new centroid. If false, KernelType will be ignored. |
KernelType | The kernel to use. |
MatType | The type of matrix the data is stored in. |
mlpack::meanshift::MeanShift< UseKernel, KernelType, MatType >::MeanShift | ( | const double | radius = 0 , |
const size_t | maxIterations = 1000 , |
||
const KernelType | kernel = KernelType() |
||
) |
Create a mean shift object and set the parameters which mean shift will be run with.
Construct the Mean Shift object.
radius | If distance of two centroids is less than it, one will be removed. If this value isn't positive, an estimation will be given when clustering. |
maxIterations | Maximum number of iterations allowed before giving up iterations will terminate. |
kernel | Optional KernelType object. |
|
inline |
Perform mean shift clustering on the data, returning a list of cluster assignments and centroids.
Perform Mean Shift clustering on the data set, returning a list of cluster assignments and centroids.
MatType | Type of matrix. |
data | Dataset to cluster. |
assignments | Vector to store cluster assignments in. |
centroids | Matrix in which centroids are stored. |
forceConvergence | Flag whether to force each centroid seed to converge regardless of maxIterations. |
useSeeds | Set true to use seeds. |
double mlpack::meanshift::MeanShift< UseKernel, KernelType, MatType >::EstimateRadius | ( | const MatType & | data, |
const double | ratio = 0.2 |
||
) |
Give an estimation of radius based on given dataset.
data | Dataset for estimation. |
ratio | Percentage of dataset to use for nearest neighbor search. |
For each point in dataset, select nNeighbors nearest points and get nNeighbors distances. Use the maximum distance to estimate the duplicate threshhold.