15 #ifndef __MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP 16 #define __MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP 22 #include <boost/utility.hpp> 48 template<
bool UseKernel =
false,
50 typename MatType = arma::mat>
67 const KernelType
kernel = KernelType());
75 double EstimateRadius(
const MatType& data,
const double ratio = 0.2);
86 void Cluster(
const MatType& data,
87 arma::Col<size_t>& assignments,
89 bool useSeeds =
true);
121 const double binSize,
133 template<
bool ApplyKernel = UseKernel>
134 typename std::enable_if<ApplyKernel, bool>::type
136 const std::vector<size_t>& neighbors,
137 const std::vector<double>& distances,
138 arma::colvec& centroid);
148 template<
bool ApplyKernel = UseKernel>
149 typename std::enable_if<!ApplyKernel, bool>::type
151 const std::vector<size_t>& neighbors,
152 const std::vector<double>&,
153 arma::colvec& centroid);
173 #include "mean_shift_impl.hpp" 175 #endif // __MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP const KernelType & Kernel() const
Get the kernel.
double Radius() const
Get the radius.
double EstimateRadius(const MatType &data, const double ratio=0.2)
Give an estimation of radius based on given dataset.
Linear algebra utility functions, generally performed on matrices or vectors.
KernelType & Kernel()
Modify the kernel.
This class implements mean shift clustering.
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.
void Cluster(const MatType &data, arma::Col< size_t > &assignments, arma::mat ¢roids, bool useSeeds=true)
Perform mean shift clustering on the data, returning a list of cluster assignments and centroids...
std::enable_if< ApplyKernel, bool >::type CalculateCentroid(const MatType &data, const std::vector< size_t > &neighbors, const std::vector< double > &distances, arma::colvec ¢roid)
Use kernel to calculate new centroid given dataset and valid neighbors.
size_t MaxIterations() const
Get the maximum number of iterations.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
size_t & MaxIterations()
Set the maximum number of iterations.
double radius
If distance of two centroids is less than radius, one will be removed.
KernelType kernel
Instantiated kernel.
The standard Gaussian kernel.
size_t maxIterations
Maximum number of iterations before giving up.
void GenSeeds(const MatType &data, const double binSize, const int minFreq, MatType &seeds)
To speed up, we can generate some seeds from data set and use them as initial centroids rather than a...