\section{Bias\+S\+V\+D\+Function$<$ Mat\+Type $>$ Class Template Reference}
\label{classmlpack_1_1svd_1_1BiasSVDFunction}\index{Bias\+S\+V\+D\+Function$<$ Mat\+Type $>$@{Bias\+S\+V\+D\+Function$<$ Mat\+Type $>$}}


This class contains methods which are used to calculate the cost of \doxyref{Bias\+S\+VD}{p.}{classmlpack_1_1svd_1_1BiasSVD}\textquotesingle{}s objective function, to calculate gradient of parameters with respect to the objective function, etc.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Bias\+S\+V\+D\+Function} (const Mat\+Type \&data, const size\+\_\+t rank, const double lambda)
\begin{DoxyCompactList}\small\item\em Constructor for \doxyref{Bias\+S\+V\+D\+Function}{p.}{classmlpack_1_1svd_1_1BiasSVDFunction} class. \end{DoxyCompactList}\item 
const arma\+::mat \& \textbf{ Dataset} () const
\begin{DoxyCompactList}\small\item\em Return the dataset passed into the constructor. \end{DoxyCompactList}\item 
double \textbf{ Evaluate} (const arma\+::mat \&parameters) const
\begin{DoxyCompactList}\small\item\em Evaluates the cost function over all examples in the data. \end{DoxyCompactList}\item 
double \textbf{ Evaluate} (const arma\+::mat \&parameters, const size\+\_\+t start, const size\+\_\+t batch\+Size=1) const
\begin{DoxyCompactList}\small\item\em Evaluates the cost function for one training example. \end{DoxyCompactList}\item 
const arma\+::mat \& \textbf{ Get\+Initial\+Point} () const
\begin{DoxyCompactList}\small\item\em Return the initial point for the optimization. \end{DoxyCompactList}\item 
void \textbf{ Gradient} (const arma\+::mat \&parameters, arma\+::mat \&gradient) const
\begin{DoxyCompactList}\small\item\em Evaluates the full gradient of the cost function over all the training examples. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Grad\+Type $>$ }\\void \textbf{ Gradient} (const arma\+::mat \&parameters, const size\+\_\+t start, Grad\+Type \&gradient, const size\+\_\+t batch\+Size=1) const
\begin{DoxyCompactList}\small\item\em Evaluates the gradient of the cost function over one training example. \end{DoxyCompactList}\item 
double \textbf{ Lambda} () const
\begin{DoxyCompactList}\small\item\em Return the regularization parameters. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Num\+Functions} () const
\begin{DoxyCompactList}\small\item\em Return the number of training examples. Useful for S\+GD optimizer. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Num\+Items} () const
\begin{DoxyCompactList}\small\item\em Return the number of items in the data. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Num\+Users} () const
\begin{DoxyCompactList}\small\item\em Return the number of users in the data. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Rank} () const
\begin{DoxyCompactList}\small\item\em Return the rank used for the factorization. \end{DoxyCompactList}\item 
void \textbf{ Shuffle} ()
\begin{DoxyCompactList}\small\item\em Shuffle the points in the dataset. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename Mat\+Type = arma\+::mat$>$\newline
class mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function$<$ Mat\+Type $>$}

This class contains methods which are used to calculate the cost of \doxyref{Bias\+S\+VD}{p.}{classmlpack_1_1svd_1_1BiasSVD}\textquotesingle{}s objective function, to calculate gradient of parameters with respect to the objective function, etc. 


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


Definition at line 31 of file bias\+\_\+svd\+\_\+function.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_ad351ac6985fcbd43a424f84407a669e6}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Bias\+S\+V\+D\+Function@{Bias\+S\+V\+D\+Function}}
\index{Bias\+S\+V\+D\+Function@{Bias\+S\+V\+D\+Function}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Bias\+S\+V\+D\+Function()}
{\footnotesize\ttfamily \textbf{ Bias\+S\+V\+D\+Function} (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{data,  }\item[{const size\+\_\+t}]{rank,  }\item[{const double}]{lambda }\end{DoxyParamCaption})}



Constructor for \doxyref{Bias\+S\+V\+D\+Function}{p.}{classmlpack_1_1svd_1_1BiasSVDFunction} class. 

The constructor calculates the number of users and items in the passed data. It also randomly initializes the parameter values.


\begin{DoxyParams}{Parameters}
{\em data} & Dataset for which S\+VD is calculated. \\
\hline
{\em rank} & Rank used for matrix factorization. \\
\hline
{\em lambda} & Regularization parameter used for optimization. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_aff320b9a86b77a150e630c01d5888273}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Dataset@{Dataset}}
\index{Dataset@{Dataset}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Dataset()}
{\footnotesize\ttfamily const arma\+::mat\& Dataset (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the dataset passed into the constructor. 



Definition at line 107 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_a6c7f979b684b70aab5bec8b09b5eb1a4}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Evaluate@{Evaluate}}
\index{Evaluate@{Evaluate}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Evaluate()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Evaluate (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters }\end{DoxyParamCaption}) const}



Evaluates the cost function over all examples in the data. 


\begin{DoxyParams}{Parameters}
{\em parameters} & Parameters(user/item matrices/bias) of the decomposition. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_a12589583139057b24a415995079f6ffe}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Evaluate@{Evaluate}}
\index{Evaluate@{Evaluate}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Evaluate()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double Evaluate (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters,  }\item[{const size\+\_\+t}]{start,  }\item[{const size\+\_\+t}]{batch\+Size = {\ttfamily 1} }\end{DoxyParamCaption}) const}



Evaluates the cost function for one training example. 

Useful for the S\+GD optimizer abstraction which uses one training example at a time.


\begin{DoxyParams}{Parameters}
{\em parameters} & Parameters(user/item matrices/bias) of the decomposition. \\
\hline
{\em start} & First index of the training examples to be used. \\
\hline
{\em batch\+Size} & Size of batch to evaluate. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_ac3e9aa612cb56d0d93f3259f4a8122bb}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Get\+Initial\+Point@{Get\+Initial\+Point}}
\index{Get\+Initial\+Point@{Get\+Initial\+Point}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Get\+Initial\+Point()}
{\footnotesize\ttfamily const arma\+::mat\& Get\+Initial\+Point (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the initial point for the optimization. 



Definition at line 104 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_ab9a604f48072ce6c08443519ff787a73}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Gradient@{Gradient}}
\index{Gradient@{Gradient}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Gradient()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily void Gradient (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters,  }\item[{arma\+::mat \&}]{gradient }\end{DoxyParamCaption}) const}



Evaluates the full gradient of the cost function over all the training examples. 


\begin{DoxyParams}{Parameters}
{\em parameters} & Parameters(user/item matrices/bias) of the decomposition. \\
\hline
{\em gradient} & Calculated gradient for the parameters. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_a5b06b7506faa0b510622078a31e88009}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Gradient@{Gradient}}
\index{Gradient@{Gradient}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Gradient()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void Gradient (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters,  }\item[{const size\+\_\+t}]{start,  }\item[{Grad\+Type \&}]{gradient,  }\item[{const size\+\_\+t}]{batch\+Size = {\ttfamily 1} }\end{DoxyParamCaption}) const}



Evaluates the gradient of the cost function over one training example. 

This function is useful for optimizers like S\+GD. The type of the gradient parameter is a template argument to allow the computation of a sparse gradient.


\begin{DoxyTemplParams}{Template Parameters}
{\em Grad\+Type} & The type of the gradient out-\/param. \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em parameters} & Parameters(user/item matrices/bias) of the decomposition. \\
\hline
{\em start} & The first index of the training examples to use. \\
\hline
{\em gradient} & Calculated gradient for the parameters. \\
\hline
{\em batch\+Size} & Size of batch to calculate gradient for. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_a53535041275cedd0ec3de67ca032aa94}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Lambda@{Lambda}}
\index{Lambda@{Lambda}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Lambda()}
{\footnotesize\ttfamily double Lambda (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the regularization parameters. 



Definition at line 119 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_a1fa76af34a6e3ea927b307f0c318ee4b}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Num\+Functions@{Num\+Functions}}
\index{Num\+Functions@{Num\+Functions}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Num\+Functions()}
{\footnotesize\ttfamily size\+\_\+t Num\+Functions (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the number of training examples. Useful for S\+GD optimizer. 



Definition at line 110 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_ad4e27ce22a8ed61cf6a83e3c1b48de3a}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Num\+Items@{Num\+Items}}
\index{Num\+Items@{Num\+Items}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Num\+Items()}
{\footnotesize\ttfamily size\+\_\+t Num\+Items (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the number of items in the data. 



Definition at line 116 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_af41355bc8f20533711975528a054c4dc}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Num\+Users@{Num\+Users}}
\index{Num\+Users@{Num\+Users}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Num\+Users()}
{\footnotesize\ttfamily size\+\_\+t Num\+Users (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the number of users in the data. 



Definition at line 113 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_afe1447c5e7fa184cbf19ced57a50b7b6}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Rank@{Rank}}
\index{Rank@{Rank}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Rank()}
{\footnotesize\ttfamily size\+\_\+t Rank (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the rank used for the factorization. 



Definition at line 122 of file bias\+\_\+svd\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1svd_1_1BiasSVDFunction_a2697cc8b37d7bca7c055228382a9b208}} 
\index{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}!Shuffle@{Shuffle}}
\index{Shuffle@{Shuffle}!mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function@{mlpack\+::svd\+::\+Bias\+S\+V\+D\+Function}}
\subsubsection{Shuffle()}
{\footnotesize\ttfamily void Shuffle (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Shuffle the points in the dataset. 

This may be used by optimizers. 

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/bias\+\_\+svd/\textbf{ bias\+\_\+svd\+\_\+function.\+hpp}\end{DoxyCompactItemize}
