13 #ifndef MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP 14 #define MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP 20 #include <boost/utility.hpp> 46 template<
bool UseKernel =
false,
48 typename MatType = arma::mat>
65 const KernelType
kernel = KernelType());
73 double EstimateRadius(
const MatType& data,
const double ratio = 0.2);
84 void Cluster(
const MatType& data,
85 arma::Col<size_t>& assignments,
87 bool useSeeds =
true);
119 const double binSize,
131 template<
bool ApplyKernel = UseKernel>
132 typename std::enable_if<ApplyKernel, bool>::type
134 const std::vector<size_t>& neighbors,
135 const std::vector<double>& distances,
136 arma::colvec& centroid);
146 template<
bool ApplyKernel = UseKernel>
147 typename std::enable_if<!ApplyKernel, bool>::type
149 const std::vector<size_t>& neighbors,
150 const std::vector<double>&,
151 arma::colvec& centroid);
171 #include "mean_shift_impl.hpp" 173 #endif // MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP
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.
The core includes that mlpack expects; standard C++ includes and Armadillo.
This class implements mean shift clustering.
size_t MaxIterations() const
Get the maximum number of iterations.
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()
Set the maximum number of iterations.
const KernelType & Kernel() const
Get the kernel.
double radius
If distance of two centroids is less than radius, one will be removed.
KernelType kernel
Instantiated kernel.
The standard Gaussian kernel.
double Radius() const
Get the radius.
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...