\section{P\+CA$<$ Decomposition\+Policy $>$ Class Template Reference}
\label{classmlpack_1_1pca_1_1PCA}\index{P\+C\+A$<$ Decomposition\+Policy $>$@{P\+C\+A$<$ Decomposition\+Policy $>$}}


This class implements principal components analysis (\doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA}).  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ P\+CA} (const bool scale\+Data=false, const Decomposition\+Policy \&decomposition=Decomposition\+Policy())
\begin{DoxyCompactList}\small\item\em Create the \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} object, specifying if the data should be scaled in each dimension by standard deviation when \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} is performed. \end{DoxyCompactList}\item 
void \textbf{ Apply} (const arma\+::mat \&data, arma\+::mat \&transformed\+Data, arma\+::vec \&eig\+Val, arma\+::mat \&eigvec)
\begin{DoxyCompactList}\small\item\em Apply Principal Component Analysis to the provided data set. \end{DoxyCompactList}\item 
void \textbf{ Apply} (const arma\+::mat \&data, arma\+::mat \&transformed\+Data, arma\+::vec \&eig\+Val)
\begin{DoxyCompactList}\small\item\em Apply Principal Component Analysis to the provided data set. \end{DoxyCompactList}\item 
double \textbf{ Apply} (arma\+::mat \&data, const size\+\_\+t new\+Dimension)
\begin{DoxyCompactList}\small\item\em Use \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} for dimensionality reduction on the given dataset. \end{DoxyCompactList}\item 
double \textbf{ Apply} (arma\+::mat \&data, const int new\+Dimension)
\begin{DoxyCompactList}\small\item\em This overload is here to make sure int gets casted right to size\+\_\+t. \end{DoxyCompactList}\item 
double \textbf{ Apply} (arma\+::mat \&data, const double var\+Retained)
\begin{DoxyCompactList}\small\item\em Use \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} for dimensionality reduction on the given dataset. \end{DoxyCompactList}\item 
bool \textbf{ Scale\+Data} () const
\begin{DoxyCompactList}\small\item\em Get whether or not this \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} object will scale (by standard deviation) the data when \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} is performed. \end{DoxyCompactList}\item 
bool \& \textbf{ Scale\+Data} ()
\begin{DoxyCompactList}\small\item\em Modify whether or not this \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} object will scale (by standard deviation) the data when \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} is performed. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename Decomposition\+Policy = Exact\+S\+V\+D\+Policy$>$\newline
class mlpack\+::pca\+::\+P\+C\+A$<$ Decomposition\+Policy $>$}

This class implements principal components analysis (\doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA}). 

This is a common, widely-\/used technique that is often used for either dimensionality reduction or transforming data into a better basis. Further information on \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} can be found in almost any statistics or machine learning textbook, and all over the internet. 

Definition at line 33 of file pca.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1pca_1_1PCA_a9f0b6d838b7e3513e262d7d996e108bb}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!P\+CA@{P\+CA}}
\index{P\+CA@{P\+CA}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{P\+C\+A()}
{\footnotesize\ttfamily \textbf{ P\+CA} (\begin{DoxyParamCaption}\item[{const bool}]{scale\+Data = {\ttfamily false},  }\item[{const Decomposition\+Policy \&}]{decomposition = {\ttfamily DecompositionPolicy()} }\end{DoxyParamCaption})}



Create the \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} object, specifying if the data should be scaled in each dimension by standard deviation when \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} is performed. 


\begin{DoxyParams}{Parameters}
{\em scale\+Data} & Whether or not to scale the data. \\
\hline
{\em decomposition} & Decomposition policy to use. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1pca_1_1PCA_a657771c335d4a28141e2abfbcba8c2e8}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [1/5]}}
{\footnotesize\ttfamily void Apply (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{data,  }\item[{arma\+::mat \&}]{transformed\+Data,  }\item[{arma\+::vec \&}]{eig\+Val,  }\item[{arma\+::mat \&}]{eigvec }\end{DoxyParamCaption})}



Apply Principal Component Analysis to the provided data set. 

It is safe to pass the same matrix reference for both data and transformed\+Data.


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em transformed\+Data} & Matrix to put results of \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} into. \\
\hline
{\em eig\+Val} & Vector to put eigenvalues into. \\
\hline
{\em eigvec} & Matrix to put eigenvectors (loadings) into. \\
\hline
\end{DoxyParams}


Referenced by P\+C\+A$<$ Decomposition\+Policy $>$\+::\+Apply().

\mbox{\label{classmlpack_1_1pca_1_1PCA_adc4a34de0f409309eb54b84d4d5a38f9}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [2/5]}}
{\footnotesize\ttfamily void Apply (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{data,  }\item[{arma\+::mat \&}]{transformed\+Data,  }\item[{arma\+::vec \&}]{eig\+Val }\end{DoxyParamCaption})}



Apply Principal Component Analysis to the provided data set. 

It is safe to pass the same matrix reference for both data and transformed\+Data.


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em transformed\+Data} & Matrix to store results of \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} in. \\
\hline
{\em eig\+Val} & Vector to put eigenvalues into. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1pca_1_1PCA_a8c94adc9f4e3147a342f8316dd70fa9d}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [3/5]}}
{\footnotesize\ttfamily double Apply (\begin{DoxyParamCaption}\item[{arma\+::mat \&}]{data,  }\item[{const size\+\_\+t}]{new\+Dimension }\end{DoxyParamCaption})}



Use \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} for dimensionality reduction on the given dataset. 

This will save the new\+Dimension largest principal components of the data and remove the rest. The parameter returned is the amount of variance of the data that is retained; this is a value between 0 and 1. For instance, a value of 0.\+9 indicates that 90\% of the variance present in the data was retained.


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em new\+Dimension} & New dimension of the data. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Amount of the variance of the data retained (between 0 and 1). 
\end{DoxyReturn}
\mbox{\label{classmlpack_1_1pca_1_1PCA_a1687d5cb3c520bde7db5d0f20ec552b4}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [4/5]}}
{\footnotesize\ttfamily double Apply (\begin{DoxyParamCaption}\item[{arma\+::mat \&}]{data,  }\item[{const int}]{new\+Dimension }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



This overload is here to make sure int gets casted right to size\+\_\+t. 



Definition at line 86 of file pca.\+hpp.



References P\+C\+A$<$ Decomposition\+Policy $>$\+::\+Apply().

\mbox{\label{classmlpack_1_1pca_1_1PCA_a8cd7abbd11cfd2b4a771a864bbf29eef}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [5/5]}}
{\footnotesize\ttfamily double Apply (\begin{DoxyParamCaption}\item[{arma\+::mat \&}]{data,  }\item[{const double}]{var\+Retained }\end{DoxyParamCaption})}



Use \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} for dimensionality reduction on the given dataset. 

This will save as many dimensions as necessary to retain at least the given amount of variance (specified by parameter var\+Retained). The amount should be between 0 and 1; if the amount is 0, then only 1 dimension will be retained. If the amount is 1, then all dimensions will be retained.

The method returns the actual amount of variance retained, which will always be greater than or equal to the var\+Retained parameter.


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em var\+Retained} & Lower bound on amount of variance to retain; should be between 0 and 1. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Actual amount of variance retained (between 0 and 1). 
\end{DoxyReturn}
\mbox{\label{classmlpack_1_1pca_1_1PCA_a3809cc3360d20521c50564e78a54ad0c}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Scale\+Data@{Scale\+Data}}
\index{Scale\+Data@{Scale\+Data}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Scale\+Data()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily bool Scale\+Data (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get whether or not this \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} object will scale (by standard deviation) the data when \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} is performed. 



Definition at line 110 of file pca.\+hpp.



Referenced by P\+C\+A$<$ Decomposition\+Policy $>$\+::\+Scale\+Data().

\mbox{\label{classmlpack_1_1pca_1_1PCA_a0e6d9cee4c4392ab92e9b21fde791402}} 
\index{mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}!Scale\+Data@{Scale\+Data}}
\index{Scale\+Data@{Scale\+Data}!mlpack\+::pca\+::\+P\+CA@{mlpack\+::pca\+::\+P\+CA}}
\subsubsection{Scale\+Data()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily bool\& Scale\+Data (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify whether or not this \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} object will scale (by standard deviation) the data when \doxyref{P\+CA}{p.}{classmlpack_1_1pca_1_1PCA} is performed. 



Definition at line 113 of file pca.\+hpp.



References P\+C\+A$<$ Decomposition\+Policy $>$\+::\+Scale\+Data().



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.\+2/src/mlpack/methods/pca/\textbf{ pca.\+hpp}\end{DoxyCompactItemize}
