\section{Kernel\+P\+CA$<$ Kernel\+Type, Kernel\+Rule $>$ Class Template Reference}
\label{classmlpack_1_1kpca_1_1KernelPCA}\index{Kernel\+P\+C\+A$<$ Kernel\+Type, Kernel\+Rule $>$@{Kernel\+P\+C\+A$<$ Kernel\+Type, Kernel\+Rule $>$}}


This class performs kernel principal components analysis (Kernel P\+CA), for a given kernel.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Kernel\+P\+CA} (const Kernel\+Type kernel=Kernel\+Type(), const bool center\+Transformed\+Data=false)
\begin{DoxyCompactList}\small\item\em Construct the \doxyref{Kernel\+P\+CA}{p.}{classmlpack_1_1kpca_1_1KernelPCA} object, optionally passing a kernel. \end{DoxyCompactList}\item 
void \textbf{ Apply} (const arma\+::mat \&data, arma\+::mat \&transformed\+Data, arma\+::vec \&eigval, arma\+::mat \&eigvec, const size\+\_\+t new\+Dimension)
\begin{DoxyCompactList}\small\item\em Apply Kernel Principal Components Analysis to the provided data set. \end{DoxyCompactList}\item 
void \textbf{ Apply} (const arma\+::mat \&data, arma\+::mat \&transformed\+Data, arma\+::vec \&eigval, arma\+::mat \&eigvec)
\begin{DoxyCompactList}\small\item\em Apply Kernel Principal Components Analysis to the provided data set. \end{DoxyCompactList}\item 
void \textbf{ Apply} (const arma\+::mat \&data, arma\+::mat \&transformed\+Data, arma\+::vec \&eigval)
\begin{DoxyCompactList}\small\item\em Apply Kernel Principal Component Analysis to the provided data set. \end{DoxyCompactList}\item 
void \textbf{ Apply} (arma\+::mat \&data, const size\+\_\+t new\+Dimension)
\begin{DoxyCompactList}\small\item\em Apply dimensionality reduction using Kernel Principal Component Analysis to the provided data set. \end{DoxyCompactList}\item 
bool \textbf{ Center\+Transformed\+Data} () const
\begin{DoxyCompactList}\small\item\em Return whether or not the transformed data is centered. \end{DoxyCompactList}\item 
bool \& \textbf{ Center\+Transformed\+Data} ()
\begin{DoxyCompactList}\small\item\em Return whether or not the transformed data is centered. \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}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename Kernel\+Type, typename Kernel\+Rule = Naive\+Kernel\+Rule$<$\+Kernel\+Type$>$$>$\newline
class mlpack\+::kpca\+::\+Kernel\+P\+C\+A$<$ Kernel\+Type, Kernel\+Rule $>$}

This class performs kernel principal components analysis (Kernel P\+CA), for a given kernel. 

This is a standard machine learning technique and is well-\/documented on the Internet and in standard texts. It is often used as a dimensionality reduction technique, and can also be useful in mapping linearly inseparable classes of points to different spaces where they are linearly separable.

The performance of the method is highly dependent on the kernel choice. There are numerous available kernels in the \doxyref{mlpack\+::kernel}{p.}{namespacemlpack_1_1kernel} namespace (see files in mlpack/core/kernels/) and it is easy to write your own; see other implementations for examples. 

Definition at line 40 of file kernel\+\_\+pca.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_acd937631070c2e90436fbc2db6cb2491}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Kernel\+P\+CA@{Kernel\+P\+CA}}
\index{Kernel\+P\+CA@{Kernel\+P\+CA}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\subsubsection{Kernel\+P\+C\+A()}
{\footnotesize\ttfamily \textbf{ Kernel\+P\+CA} (\begin{DoxyParamCaption}\item[{const Kernel\+Type}]{kernel = {\ttfamily KernelType()},  }\item[{const bool}]{center\+Transformed\+Data = {\ttfamily false} }\end{DoxyParamCaption})}



Construct the \doxyref{Kernel\+P\+CA}{p.}{classmlpack_1_1kpca_1_1KernelPCA} object, optionally passing a kernel. 

Optionally, the transformed data can be centered about the origin; to do this, pass \textquotesingle{}true\textquotesingle{} for center\+Transformed\+Data. This will take slightly longer (but not much).


\begin{DoxyParams}{Parameters}
{\em kernel} & Kernel to be used for computation. \\
\hline
{\em center\+Transformed\+Data} & Center transformed data. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_a856a3d7bb0dca4d5beaca3710b9da857}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily void Apply (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{data,  }\item[{arma\+::mat \&}]{transformed\+Data,  }\item[{arma\+::vec \&}]{eigval,  }\item[{arma\+::mat \&}]{eigvec,  }\item[{const size\+\_\+t}]{new\+Dimension }\end{DoxyParamCaption})}



Apply Kernel Principal Components Analysis to the provided data set. 


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em transformed\+Data} & Matrix to output results into. \\
\hline
{\em eigval} & K\+P\+CA eigenvalues will be written to this vector. \\
\hline
{\em eigvec} & K\+P\+CA eigenvectors will be written to this matrix. \\
\hline
{\em new\+Dimension} & New dimension for the dataset. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_aafe044ec4b7a51e09c8820e26e5704d3}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily void Apply (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{data,  }\item[{arma\+::mat \&}]{transformed\+Data,  }\item[{arma\+::vec \&}]{eigval,  }\item[{arma\+::mat \&}]{eigvec }\end{DoxyParamCaption})}



Apply Kernel Principal Components Analysis to the provided data set. 


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em transformed\+Data} & Matrix to output results into. \\
\hline
{\em eigval} & K\+P\+CA eigenvalues will be written to this vector. \\
\hline
{\em eigvec} & K\+P\+CA eigenvectors will be written to this matrix. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_af7512c50d7e08e2dff7a574613e45840}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily void Apply (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{data,  }\item[{arma\+::mat \&}]{transformed\+Data,  }\item[{arma\+::vec \&}]{eigval }\end{DoxyParamCaption})}



Apply Kernel Principal Component Analysis to the provided data set. 


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em transformed\+Data} & Matrix to output results into. \\
\hline
{\em eigval} & K\+P\+CA eigenvalues will be written to this vector. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_afe19e2aabe4af32fac98d18297c35316}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Apply@{Apply}}
\index{Apply@{Apply}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\subsubsection{Apply()\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily void Apply (\begin{DoxyParamCaption}\item[{arma\+::mat \&}]{data,  }\item[{const size\+\_\+t}]{new\+Dimension }\end{DoxyParamCaption})}



Apply dimensionality reduction using Kernel Principal Component Analysis to the provided data set. 

The data matrix will be modified in-\/place. Note that the dimension can be larger than the existing dimension because K\+P\+CA works on the kernel matrix, not the covariance matrix. This means the new dimension can be as large as the number of points (columns) in the dataset. Note that if you specify new\+Dimension to be larger than the current dimension of the data (the number of rows), then it\textquotesingle{}s not really \char`\"{}dimensionality reduction\char`\"{}...


\begin{DoxyParams}{Parameters}
{\em data} & Data matrix. \\
\hline
{\em new\+Dimension} & New dimension for the dataset. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_aac3950c39b833cdb3c7b521530acd255}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Center\+Transformed\+Data@{Center\+Transformed\+Data}}
\index{Center\+Transformed\+Data@{Center\+Transformed\+Data}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\subsubsection{Center\+Transformed\+Data()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily bool Center\+Transformed\+Data (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return whether or not the transformed data is centered. 



Definition at line 115 of file kernel\+\_\+pca.\+hpp.

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



Return whether or not the transformed data is centered. 



Definition at line 117 of file kernel\+\_\+pca.\+hpp.

\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_a917492b75cc17298bc58c3d28e2944fb}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Kernel@{Kernel}}
\index{Kernel@{Kernel}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\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 110 of file kernel\+\_\+pca.\+hpp.

\mbox{\label{classmlpack_1_1kpca_1_1KernelPCA_ab8d1bedeac8344d80e50d819790a117a}} 
\index{mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}!Kernel@{Kernel}}
\index{Kernel@{Kernel}!mlpack\+::kpca\+::\+Kernel\+P\+CA@{mlpack\+::kpca\+::\+Kernel\+P\+CA}}
\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 112 of file kernel\+\_\+pca.\+hpp.



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/kernel\+\_\+pca/\textbf{ kernel\+\_\+pca.\+hpp}\end{DoxyCompactItemize}
