\section{Pearson\+Search Class Reference}
\label{classmlpack_1_1cf_1_1PearsonSearch}\index{Pearson\+Search@{Pearson\+Search}}


Nearest neighbor search with pearson distance (or furthest neighbor search with pearson correlation).  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Pearson\+Search} (const arma\+::mat \&reference\+Set)
\begin{DoxyCompactList}\small\item\em Constructor with reference set. \end{DoxyCompactList}\item 
void \textbf{ Search} (const arma\+::mat \&query, const size\+\_\+t k, arma\+::\+Mat$<$ size\+\_\+t $>$ \&neighbors, arma\+::mat \&similarities)
\begin{DoxyCompactList}\small\item\em Given a set of query points, find the nearest k neighbors, and return similarities. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Nearest neighbor search with pearson distance (or furthest neighbor search with pearson correlation). 

Note that, with normalized vectors, neighbor search with pearson distance is equivalent to neighbor search with Euclidean distance. Therefore, instead of performing neighbor search directly with pearson distance, we first normalize all vectors, and then use \doxyref{neighbor\+::\+K\+NN}{p.}{namespacemlpack_1_1neighbor_ac8d70069e8acb12c5ba9a8536ae6ace4} (i.\+e. Neighbor\+Search with Euclidean distance, K\+D\+Tree). Pearson correlation are calculated from Euclidean distance.

An example of how to use \doxyref{Pearson\+Search}{p.}{classmlpack_1_1cf_1_1PearsonSearch} in CF is shown below\+:


\begin{DoxyCode}
\textcolor{keyword}{extern} arma::mat data; \textcolor{comment}{// data is a (user, item, rating) table.}
\textcolor{comment}{// Users for whom recommendations are generated.}
\textcolor{keyword}{extern} arma::Col<size\_t> users;
arma::Mat<size\_t> recommendations; \textcolor{comment}{// Resulting recommendations.}

CFType<> cf(data);

\textcolor{comment}{// Generate 10 recommendations for all users.}
cf.template GetRecommendations<PearsonSearch>(10, recommendations);
\end{DoxyCode}
 

Definition at line 45 of file pearson\+\_\+search.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1cf_1_1PearsonSearch_affe8eece29c0967f401bf689bf324c23}} 
\index{mlpack\+::cf\+::\+Pearson\+Search@{mlpack\+::cf\+::\+Pearson\+Search}!Pearson\+Search@{Pearson\+Search}}
\index{Pearson\+Search@{Pearson\+Search}!mlpack\+::cf\+::\+Pearson\+Search@{mlpack\+::cf\+::\+Pearson\+Search}}
\subsubsection{Pearson\+Search()}
{\footnotesize\ttfamily \textbf{ Pearson\+Search} (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{reference\+Set }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Constructor with reference set. 

In order to use \doxyref{neighbor\+::\+K\+NN}{p.}{namespacemlpack_1_1neighbor_ac8d70069e8acb12c5ba9a8536ae6ace4}(i.\+e. Neighbor\+Search with Euclidean distance, K\+D\+Tree), we need to normalize all vectors in reference\+Set. For each vector x, we first subtract mean(x) from each element in x. Then, we normalize the vector to unit length.


\begin{DoxyParams}{Parameters}
{\em Set} & of reference points. \\
\hline
\end{DoxyParams}


Definition at line 57 of file pearson\+\_\+search.\+hpp.



References Neighbor\+Search$<$ Sort\+Policy, Metric\+Type, Mat\+Type, Tree\+Type, Dual\+Tree\+Traversal\+Type, Single\+Tree\+Traversal\+Type $>$\+::\+Train().



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1cf_1_1PearsonSearch_a5ce7aae85679ed26a716bcb8d7c8ee7b}} 
\index{mlpack\+::cf\+::\+Pearson\+Search@{mlpack\+::cf\+::\+Pearson\+Search}!Search@{Search}}
\index{Search@{Search}!mlpack\+::cf\+::\+Pearson\+Search@{mlpack\+::cf\+::\+Pearson\+Search}}
\subsubsection{Search()}
{\footnotesize\ttfamily void Search (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{query,  }\item[{const size\+\_\+t}]{k,  }\item[{arma\+::\+Mat$<$ size\+\_\+t $>$ \&}]{neighbors,  }\item[{arma\+::mat \&}]{similarities }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Given a set of query points, find the nearest k neighbors, and return similarities. 

Similarities are non-\/negative and no larger than one.


\begin{DoxyParams}{Parameters}
{\em query} & A set of query points. \\
\hline
{\em k} & Number of neighbors to search. \\
\hline
{\em neighbors} & Nearest neighbors. \\
\hline
{\em similarites} & Similarities between query point and its neighbors. \\
\hline
\end{DoxyParams}


Definition at line 78 of file pearson\+\_\+search.\+hpp.



References Neighbor\+Search$<$ Sort\+Policy, Metric\+Type, Mat\+Type, Tree\+Type, Dual\+Tree\+Traversal\+Type, Single\+Tree\+Traversal\+Type $>$\+::\+Search().



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.\+1/src/mlpack/methods/cf/neighbor\+\_\+search\+\_\+policies/\textbf{ pearson\+\_\+search.\+hpp}\end{DoxyCompactItemize}
