\section{Mean\+Shift$<$ Use\+Kernel, Kernel\+Type, Mat\+Type $>$ Class Template Reference}
\label{classmlpack_1_1meanshift_1_1MeanShift}\index{Mean\+Shift$<$ Use\+Kernel, Kernel\+Type, Mat\+Type $>$@{Mean\+Shift$<$ Use\+Kernel, Kernel\+Type, Mat\+Type $>$}}


This class implements mean shift clustering.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Mean\+Shift} (const double radius=0, const size\+\_\+t max\+Iterations=1000, const Kernel\+Type kernel=Kernel\+Type())
\begin{DoxyCompactList}\small\item\em Create a mean shift object and set the parameters which mean shift will be run with. \end{DoxyCompactList}\item 
void \textbf{ Cluster} (const Mat\+Type \&data, arma\+::\+Row$<$ size\+\_\+t $>$ \&assignments, arma\+::mat \&centroids, bool force\+Convergence=true, bool use\+Seeds=true)
\begin{DoxyCompactList}\small\item\em Perform mean shift clustering on the data, returning a list of cluster assignments and centroids. \end{DoxyCompactList}\item 
double \textbf{ Estimate\+Radius} (const Mat\+Type \&data, const double ratio=0.\+2)
\begin{DoxyCompactList}\small\item\em Give an estimation of radius based on given dataset. \end{DoxyCompactList}\item 
const Kernel\+Type \& \textbf{ Kernel} () const
\begin{DoxyCompactList}\small\item\em Get the kernel. \end{DoxyCompactList}\item 
Kernel\+Type \& \textbf{ Kernel} ()
\begin{DoxyCompactList}\small\item\em Modify the kernel. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Max\+Iterations} () const
\begin{DoxyCompactList}\small\item\em Get the maximum number of iterations. \end{DoxyCompactList}\item 
size\+\_\+t \& \textbf{ Max\+Iterations} ()
\begin{DoxyCompactList}\small\item\em Set the maximum number of iterations. \end{DoxyCompactList}\item 
double \textbf{ Radius} () const
\begin{DoxyCompactList}\small\item\em Get the radius. \end{DoxyCompactList}\item 
void \textbf{ Radius} (double radius)
\begin{DoxyCompactList}\small\item\em Set the radius. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$bool Use\+Kernel = false, typename Kernel\+Type = kernel\+::\+Gaussian\+Kernel, typename Mat\+Type = arma\+::mat$>$\newline
class mlpack\+::meanshift\+::\+Mean\+Shift$<$ Use\+Kernel, Kernel\+Type, Mat\+Type $>$}

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.


\begin{DoxyCode}
\textcolor{keyword}{extern} arma::mat data; \textcolor{comment}{// Dataset we want to run mean shift on.}
arma::Row<size\_t> assignments; \textcolor{comment}{// Cluster assignments.}
arma::mat centroids; \textcolor{comment}{// Cluster centroids.}
\textcolor{keywordtype}{bool} forceConvergence = \textcolor{keyword}{true}; \textcolor{comment}{// Flag whether to force each centroid seed}
to converge regardless of maxIterations.

MeanShift<> meanShift();
meanShift.Cluster(dataset, assignments, centroids, forceConvergence);
\end{DoxyCode}



\begin{DoxyTemplParams}{Template Parameters}
{\em Use\+Kernel} & Use kernel or mean to calculate new centroid. If false, Kernel\+Type will be ignored. \\
\hline
{\em Kernel\+Type} & The kernel to use. \\
\hline
{\em Mat\+Type} & The type of matrix the data is stored in. \\
\hline
\end{DoxyTemplParams}


Definition at line 51 of file mean\+\_\+shift.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_a2d412008ae2244778bfd2afb1e292858}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Mean\+Shift@{Mean\+Shift}}
\index{Mean\+Shift@{Mean\+Shift}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Mean\+Shift()}
{\footnotesize\ttfamily \textbf{ Mean\+Shift} (\begin{DoxyParamCaption}\item[{const double}]{radius = {\ttfamily 0},  }\item[{const size\+\_\+t}]{max\+Iterations = {\ttfamily 1000},  }\item[{const Kernel\+Type}]{kernel = {\ttfamily KernelType()} }\end{DoxyParamCaption})}



Create a mean shift object and set the parameters which mean shift will be run with. 


\begin{DoxyParams}{Parameters}
{\em radius} & If distance of two centroids is less than it, one will be removed. If this value isn\textquotesingle{}t positive, an estimation will be given when clustering. \\
\hline
{\em max\+Iterations} & Maximum number of iterations allowed before giving up iterations will terminate. \\
\hline
{\em kernel} & Optional Kernel\+Type object. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_ae6c156618ab407e37eb42f6843e46005}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Cluster@{Cluster}}
\index{Cluster@{Cluster}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Cluster()}
{\footnotesize\ttfamily void Cluster (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{data,  }\item[{arma\+::\+Row$<$ size\+\_\+t $>$ \&}]{assignments,  }\item[{arma\+::mat \&}]{centroids,  }\item[{bool}]{force\+Convergence = {\ttfamily true},  }\item[{bool}]{use\+Seeds = {\ttfamily true} }\end{DoxyParamCaption})}



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


\begin{DoxyTemplParams}{Template Parameters}
{\em Mat\+Type} & Type of matrix. \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & Dataset to cluster. \\
\hline
{\em assignments} & Vector to store cluster assignments in. \\
\hline
{\em centroids} & Matrix in which centroids are stored. \\
\hline
{\em force\+Convergence} & Flag whether to force each centroid seed to converge regardless of max\+Iterations. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_a18e16a5764b4b09cd46402c5ac40e711}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Estimate\+Radius@{Estimate\+Radius}}
\index{Estimate\+Radius@{Estimate\+Radius}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Estimate\+Radius()}
{\footnotesize\ttfamily double Estimate\+Radius (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{data,  }\item[{const double}]{ratio = {\ttfamily 0.2} }\end{DoxyParamCaption})}



Give an estimation of radius based on given dataset. 


\begin{DoxyParams}{Parameters}
{\em data} & Dataset for estimation. \\
\hline
{\em ratio} & Percentage of dataset to use for nearest neighbor search. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_a917492b75cc17298bc58c3d28e2944fb}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Kernel@{Kernel}}
\index{Kernel@{Kernel}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Kernel()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const Kernel\+Type\& Kernel (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the kernel. 



Definition at line 105 of file mean\+\_\+shift.\+hpp.

\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_ab8d1bedeac8344d80e50d819790a117a}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Kernel@{Kernel}}
\index{Kernel@{Kernel}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Kernel()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Kernel\+Type\& Kernel (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify the kernel. 



Definition at line 107 of file mean\+\_\+shift.\+hpp.

\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_a420770944a5b0c7a852c4ec372c4a2d1}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Max\+Iterations@{Max\+Iterations}}
\index{Max\+Iterations@{Max\+Iterations}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Max\+Iterations()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily size\+\_\+t Max\+Iterations (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the maximum number of iterations. 



Definition at line 95 of file mean\+\_\+shift.\+hpp.

\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_acda675ab4ab86b95c92bc33bc391a61b}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Max\+Iterations@{Max\+Iterations}}
\index{Max\+Iterations@{Max\+Iterations}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Max\+Iterations()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily size\+\_\+t\& Max\+Iterations (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Set the maximum number of iterations. 



Definition at line 97 of file mean\+\_\+shift.\+hpp.

\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_a02d5a1a7e8669d3c22506ecd9a811df8}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Radius@{Radius}}
\index{Radius@{Radius}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Radius()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Radius (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the radius. 



Definition at line 100 of file mean\+\_\+shift.\+hpp.

\mbox{\label{classmlpack_1_1meanshift_1_1MeanShift_ae12840857c3632026e7c513e0f19e52d}} 
\index{mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}!Radius@{Radius}}
\index{Radius@{Radius}!mlpack\+::meanshift\+::\+Mean\+Shift@{mlpack\+::meanshift\+::\+Mean\+Shift}}
\subsubsection{Radius()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void Radius (\begin{DoxyParamCaption}\item[{double}]{radius }\end{DoxyParamCaption})}



Set the radius. 



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+0/src/mlpack/methods/mean\+\_\+shift/\textbf{ mean\+\_\+shift.\+hpp}\end{DoxyCompactItemize}
