MeanShift< UseKernel, KernelType, MatType > Class Template Reference

This class implements mean shift clustering. More...

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...

 
void Cluster (const MatType &data, arma::Row< size_t > &assignments, arma::mat &centroids, bool forceConvergence=true, bool useSeeds=true)
 Perform mean shift clustering on the data, returning a list of cluster assignments and centroids. More...

 
double EstimateRadius (const MatType &data, const double ratio=0.2)
 Give an estimation of radius based on given dataset. More...

 
const KernelType & Kernel () const
 Get the kernel. More...

 
KernelType & Kernel ()
 Modify the kernel. More...

 
size_t MaxIterations () const
 Get the maximum number of iterations. More...

 
size_t & MaxIterations ()
 Set the maximum number of iterations. More...

 
double Radius () const
 Get the radius. More...

 
void Radius (double radius)
 Set the radius. More...

 

Detailed Description


template<bool UseKernel = false, typename KernelType = kernel::GaussianKernel, typename MatType = arma::mat>
class mlpack::meanshift::MeanShift< UseKernel, KernelType, MatType >

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.

extern arma::mat data; // Dataset we want to run mean shift on.
arma::Row<size_t> assignments; // Cluster assignments.
arma::mat centroids; // Cluster centroids.
bool forceConvergence = true; // Flag whether to force each centroid seed
to converge regardless of maxIterations.
MeanShift<> meanShift();
meanShift.Cluster(dataset, assignments, centroids, forceConvergence);
Template Parameters
UseKernelUse kernel or mean to calculate new centroid. If false, KernelType will be ignored.
KernelTypeThe kernel to use.
MatTypeThe type of matrix the data is stored in.

Definition at line 50 of file mean_shift.hpp.

Constructor & Destructor Documentation

◆ MeanShift()

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.

Parameters
radiusIf 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.
maxIterationsMaximum number of iterations allowed before giving up iterations will terminate.
kernelOptional KernelType object.

Member Function Documentation

◆ Cluster()

void Cluster ( const MatType &  data,
arma::Row< size_t > &  assignments,
arma::mat &  centroids,
bool  forceConvergence = true,
bool  useSeeds = true 
)

Perform mean shift clustering on the data, returning a list of cluster assignments and centroids.

Template Parameters
MatTypeType of matrix.
Parameters
dataDataset to cluster.
assignmentsVector to store cluster assignments in.
centroidsMatrix in which centroids are stored.
forceConvergenceFlag whether to force each centroid seed to converge regardless of maxIterations.
useSeedsSet true to use seeds.

◆ EstimateRadius()

double EstimateRadius ( const MatType &  data,
const double  ratio = 0.2 
)

Give an estimation of radius based on given dataset.

Parameters
dataDataset for estimation.
ratioPercentage of dataset to use for nearest neighbor search.

◆ Kernel() [1/2]

const KernelType& Kernel ( ) const
inline

Get the kernel.

Definition at line 105 of file mean_shift.hpp.

◆ Kernel() [2/2]

KernelType& Kernel ( )
inline

Modify the kernel.

Definition at line 107 of file mean_shift.hpp.

◆ MaxIterations() [1/2]

size_t MaxIterations ( ) const
inline

Get the maximum number of iterations.

Definition at line 95 of file mean_shift.hpp.

◆ MaxIterations() [2/2]

size_t& MaxIterations ( )
inline

Set the maximum number of iterations.

Definition at line 97 of file mean_shift.hpp.

◆ Radius() [1/2]

double Radius ( ) const
inline

Get the radius.

Definition at line 100 of file mean_shift.hpp.

◆ Radius() [2/2]

void Radius ( double  radius)

Set the radius.


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/mean_shift/mean_shift.hpp