\section{Logistic\+Regression\+Function$<$ Mat\+Type $>$ Class Template Reference}
\label{classmlpack_1_1regression_1_1LogisticRegressionFunction}\index{Logistic\+Regression\+Function$<$ Mat\+Type $>$@{Logistic\+Regression\+Function$<$ Mat\+Type $>$}}


The log-\/likelihood function for the logistic regression objective function.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Logistic\+Regression\+Function} (const Mat\+Type \&predictors, const arma\+::\+Row$<$ size\+\_\+t $>$ \&responses, const double lambda=0)
\begin{DoxyCompactList}\small\item\em Creates the \doxyref{Logistic\+Regression\+Function}{p.}{classmlpack_1_1regression_1_1LogisticRegressionFunction}. \end{DoxyCompactList}\item 
double \textbf{ Evaluate} (const arma\+::mat \&parameters) const
\begin{DoxyCompactList}\small\item\em Evaluate the logistic regression log-\/likelihood function with the given parameters. \end{DoxyCompactList}\item 
double \textbf{ Evaluate} (const arma\+::mat \&parameters, const size\+\_\+t begin, const size\+\_\+t batch\+Size=1) const
\begin{DoxyCompactList}\small\item\em Evaluate the logistic regression log-\/likelihood function with the given parameters using the given batch size from the given point index. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Grad\+Type $>$ }\\double \textbf{ Evaluate\+With\+Gradient} (const arma\+::mat \&parameters, Grad\+Type \&gradient) const
\begin{DoxyCompactList}\small\item\em Evaluate the objective function and gradient of the logistic regression log-\/likelihood function simultaneously with the given parameters. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Grad\+Type $>$ }\\double \textbf{ Evaluate\+With\+Gradient} (const arma\+::mat \&parameters, const size\+\_\+t begin, Grad\+Type \&gradient, const size\+\_\+t batch\+Size=1) const
\begin{DoxyCompactList}\small\item\em Evaluate the objective function and gradient of the logistic regression log-\/likelihood function simultaneously with the given parameters, for the given batch size from a given point in the dataset. \end{DoxyCompactList}\item 
void \textbf{ Gradient} (const arma\+::mat \&parameters, arma\+::mat \&gradient) const
\begin{DoxyCompactList}\small\item\em Evaluate the gradient of the logistic regression log-\/likelihood function with the given parameters. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Grad\+Type $>$ }\\void \textbf{ Gradient} (const arma\+::mat \&parameters, const size\+\_\+t begin, Grad\+Type \&gradient, const size\+\_\+t batch\+Size=1) const
\begin{DoxyCompactList}\small\item\em Evaluate the gradient of the logistic regression log-\/likelihood function with the given parameters, for the given batch size from a given point in the dataset. \end{DoxyCompactList}\item 
const double \& \textbf{ Lambda} () const
\begin{DoxyCompactList}\small\item\em Return the regularization parameter (lambda). \end{DoxyCompactList}\item 
double \& \textbf{ Lambda} ()
\begin{DoxyCompactList}\small\item\em Modify the regularization parameter (lambda). \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Num\+Features} () const
\begin{DoxyCompactList}\small\item\em Return the number of features(add 1 for the intercept term). \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Num\+Functions} () const
\begin{DoxyCompactList}\small\item\em Return the number of separable functions (the number of predictor points). \end{DoxyCompactList}\item 
void \textbf{ Partial\+Gradient} (const arma\+::mat \&parameters, const size\+\_\+t j, arma\+::sp\+\_\+mat \&gradient) const
\begin{DoxyCompactList}\small\item\em Evaluate the gradient of the logistic regression log-\/likelihood function with the given parameters, and with respect to only one feature in the dataset. \end{DoxyCompactList}\item 
const Mat\+Type \& \textbf{ Predictors} () const
\begin{DoxyCompactList}\small\item\em Return the matrix of predictors. \end{DoxyCompactList}\item 
const arma\+::\+Row$<$ size\+\_\+t $>$ \& \textbf{ Responses} () const
\begin{DoxyCompactList}\small\item\em Return the vector of responses. \end{DoxyCompactList}\item 
void \textbf{ Shuffle} ()
\begin{DoxyCompactList}\small\item\em Shuffle the order of function visitation. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename Mat\+Type = arma\+::mat$>$\newline
class mlpack\+::regression\+::\+Logistic\+Regression\+Function$<$ Mat\+Type $>$}

The log-\/likelihood function for the logistic regression objective function. 

This is used by various mlpack optimizers to train a logistic regression model. 

Definition at line 30 of file logistic\+\_\+regression\+\_\+function.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a765a1a86d5e7265054f6944fc49f00a5}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Logistic\+Regression\+Function@{Logistic\+Regression\+Function}}
\index{Logistic\+Regression\+Function@{Logistic\+Regression\+Function}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Logistic\+Regression\+Function()}
{\footnotesize\ttfamily \textbf{ Logistic\+Regression\+Function} (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{predictors,  }\item[{const arma\+::\+Row$<$ size\+\_\+t $>$ \&}]{responses,  }\item[{const double}]{lambda = {\ttfamily 0} }\end{DoxyParamCaption})}



Creates the \doxyref{Logistic\+Regression\+Function}{p.}{classmlpack_1_1regression_1_1LogisticRegressionFunction}. 


\begin{DoxyParams}{Parameters}
{\em predictors} & The matrix of data points. \\
\hline
{\em responses} & The measured data for each point in predictors. \\
\hline
{\em lambda} & Regularization constant for ridge regression. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a6c7f979b684b70aab5bec8b09b5eb1a4}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Evaluate@{Evaluate}}
\index{Evaluate@{Evaluate}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Evaluate()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Evaluate (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters }\end{DoxyParamCaption}) const}



Evaluate the logistic regression log-\/likelihood function with the given parameters. 

Note that if a point has 0 probability of being classified directly with the given parameters, then \doxyref{Evaluate()}{p.}{classmlpack_1_1regression_1_1LogisticRegressionFunction_a6c7f979b684b70aab5bec8b09b5eb1a4} will return nan (this is kind of a corner case and should not happen for reasonable models).

The optimum (minimum) of this function is 0.\+0, and occurs when each point is classified correctly with very high probability.


\begin{DoxyParams}{Parameters}
{\em parameters} & Vector of logistic regression parameters. \\
\hline
\end{DoxyParams}


Referenced by Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Responses().

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_ab6d965cc736ee801a67639099555d941}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Evaluate@{Evaluate}}
\index{Evaluate@{Evaluate}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+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}]{begin,  }\item[{const size\+\_\+t}]{batch\+Size = {\ttfamily 1} }\end{DoxyParamCaption}) const}



Evaluate the logistic regression log-\/likelihood function with the given parameters using the given batch size from the given point index. 

This is useful for optimizers such as S\+GD, which require a separable objective function. Note that if the points have 0 probability of being classified correctly with the given parameters, then \doxyref{Evaluate()}{p.}{classmlpack_1_1regression_1_1LogisticRegressionFunction_a6c7f979b684b70aab5bec8b09b5eb1a4} will return nan (this is kind of a corner case and should not happen for reasonable models).

The optimum (minimum) of this function is 0.\+0, and occurs when the points are classified correctly with very high probability.


\begin{DoxyParams}{Parameters}
{\em parameters} & Vector of logistic regression parameters. \\
\hline
{\em begin} & Index of the starting point to use for objective function evaluation. \\
\hline
{\em batch\+Size} & Number of points to be passed at a time to use for objective function evaluation. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a1e5f0be6eadfa83bbea6f6152d04f735}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Evaluate\+With\+Gradient@{Evaluate\+With\+Gradient}}
\index{Evaluate\+With\+Gradient@{Evaluate\+With\+Gradient}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Evaluate\+With\+Gradient()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Evaluate\+With\+Gradient (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters,  }\item[{Grad\+Type \&}]{gradient }\end{DoxyParamCaption}) const}



Evaluate the objective function and gradient of the logistic regression log-\/likelihood function simultaneously with the given parameters. 



Referenced by Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Responses().

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_ad39766abb8328346c4ef653a1a348390}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Evaluate\+With\+Gradient@{Evaluate\+With\+Gradient}}
\index{Evaluate\+With\+Gradient@{Evaluate\+With\+Gradient}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Evaluate\+With\+Gradient()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double Evaluate\+With\+Gradient (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters,  }\item[{const size\+\_\+t}]{begin,  }\item[{Grad\+Type \&}]{gradient,  }\item[{const size\+\_\+t}]{batch\+Size = {\ttfamily 1} }\end{DoxyParamCaption}) const}



Evaluate the objective function and gradient of the logistic regression log-\/likelihood function simultaneously with the given parameters, for the given batch size from a given point in the dataset. 

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_ab9a604f48072ce6c08443519ff787a73}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Gradient@{Gradient}}
\index{Gradient@{Gradient}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+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}



Evaluate the gradient of the logistic regression log-\/likelihood function with the given parameters. 


\begin{DoxyParams}{Parameters}
{\em parameters} & Vector of logistic regression parameters. \\
\hline
{\em gradient} & Vector to output gradient into. \\
\hline
\end{DoxyParams}


Referenced by Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Responses().

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a37df3124fb75373359e32fe1c0aacb30}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Gradient@{Gradient}}
\index{Gradient@{Gradient}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+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}]{begin,  }\item[{Grad\+Type \&}]{gradient,  }\item[{const size\+\_\+t}]{batch\+Size = {\ttfamily 1} }\end{DoxyParamCaption}) const}



Evaluate the gradient of the logistic regression log-\/likelihood function with the given parameters, for the given batch size from a given point in the dataset. 

This is useful for optimizers such as S\+GD, which require a separable objective function.


\begin{DoxyParams}{Parameters}
{\em parameters} & Vector of logistic regression parameters. \\
\hline
{\em begin} & Index of the starting point to use for objective function gradient evaluation. \\
\hline
{\em gradient} & Vector to output gradient into. \\
\hline
{\em batch\+Size} & Number of points to be processed as a batch for objective function gradient evaluation. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_aedf1f261c4ef819f2b24abcc8ebae412}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Lambda@{Lambda}}
\index{Lambda@{Lambda}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Lambda()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const double\& Lambda (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the regularization parameter (lambda). 



Definition at line 45 of file logistic\+\_\+regression\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_aaf66629b989a326453647f42443c6a0c}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Lambda@{Lambda}}
\index{Lambda@{Lambda}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Lambda()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double\& Lambda (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Modify the regularization parameter (lambda). 



Definition at line 47 of file logistic\+\_\+regression\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a351704783f122196cf5dc7fb408b8522}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Num\+Features@{Num\+Features}}
\index{Num\+Features@{Num\+Features}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Num\+Features()}
{\footnotesize\ttfamily size\+\_\+t Num\+Features (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the number of features(add 1 for the intercept term). 



Definition at line 159 of file logistic\+\_\+regression\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a1fa76af34a6e3ea927b307f0c318ee4b}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Num\+Functions@{Num\+Functions}}
\index{Num\+Functions@{Num\+Functions}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Num\+Functions()}
{\footnotesize\ttfamily size\+\_\+t Num\+Functions (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the number of separable functions (the number of predictor points). 



Definition at line 156 of file logistic\+\_\+regression\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_aebc7a3602e18648021b93c1d725fef9c}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Partial\+Gradient@{Partial\+Gradient}}
\index{Partial\+Gradient@{Partial\+Gradient}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Partial\+Gradient()}
{\footnotesize\ttfamily void Partial\+Gradient (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{parameters,  }\item[{const size\+\_\+t}]{j,  }\item[{arma\+::sp\+\_\+mat \&}]{gradient }\end{DoxyParamCaption}) const}



Evaluate the gradient of the logistic regression log-\/likelihood function with the given parameters, and with respect to only one feature in the dataset. 

This is useful for optimizers such as S\+CD, which require partial gradients.


\begin{DoxyParams}{Parameters}
{\em parameters} & Vector of logistic regression parameters. \\
\hline
{\em j} & Index of the feature with respect to which the gradient is to be computed. \\
\hline
{\em gradient} & Sparse matrix to output gradient into. \\
\hline
\end{DoxyParams}


Referenced by Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Responses().

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_af17881eecaf6b595d92c50f513b83803}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Predictors@{Predictors}}
\index{Predictors@{Predictors}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Predictors()}
{\footnotesize\ttfamily const Mat\+Type\& Predictors (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the matrix of predictors. 



Definition at line 50 of file logistic\+\_\+regression\+\_\+function.\+hpp.

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a99080f78992e0002dd030a9ed23b435c}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Responses@{Responses}}
\index{Responses@{Responses}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Responses()}
{\footnotesize\ttfamily const arma\+::\+Row$<$size\+\_\+t$>$\& Responses (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the vector of responses. 



Definition at line 52 of file logistic\+\_\+regression\+\_\+function.\+hpp.



References Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Evaluate(), Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Evaluate\+With\+Gradient(), Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Gradient(), Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Partial\+Gradient(), and Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Shuffle().

\mbox{\label{classmlpack_1_1regression_1_1LogisticRegressionFunction_a2697cc8b37d7bca7c055228382a9b208}} 
\index{mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}!Shuffle@{Shuffle}}
\index{Shuffle@{Shuffle}!mlpack\+::regression\+::\+Logistic\+Regression\+Function@{mlpack\+::regression\+::\+Logistic\+Regression\+Function}}
\subsubsection{Shuffle()}
{\footnotesize\ttfamily void Shuffle (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Shuffle the order of function visitation. 

This may be called by the optimizer. 

Referenced by Logistic\+Regression\+Function$<$ Mat\+Type $>$\+::\+Responses().



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