From e7c62bab1fc83f08205f2a2399bf8faf0f793e4b Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Tue, 2 Apr 2019 19:57:14 +0530 Subject: [PATCH 1/5] complete documentation --- .../logistic_regression/logistic_regression_function.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp index e531930901..35d6d5c32f 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp @@ -142,6 +142,11 @@ class LogisticRegressionFunction double EvaluateWithGradient(const arma::mat& parameters, GradType& gradient) 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 the in dataset. + */ template double EvaluateWithGradient(const arma::mat& parameters, const size_t begin, From 3bacfbc08dc52e4f82ab9eeb060f0c08289fcfe2 Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Thu, 4 Apr 2019 15:03:18 +0530 Subject: [PATCH 2/5] correct and completes documentation --- .../logistic_regression_function.hpp | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp index 35d6d5c32f..524beec83b 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp @@ -28,10 +28,25 @@ template class LogisticRegressionFunction { public: - LogisticRegressionFunction(const MatType& predictors, + /** + * Creates the LogisticRegressionFunction. + * + * @param predictors X, matrix of data points. + * @param responses y, the measured data for each point in X. + * @param lambda Regularization constant for ridge regression. + */ + LogisticRegressionFunction(const MatType& predictors, const arma::Row& responses, const double lambda = 0); + /** + * Creates the LogisticRegressionFunction with initialPoint. + * + * @param predictors X, matrix of data points. + * @param responses y, the measured data for each point in X. + * @param initialPoint from which to start the optimization. + * @param lambda Regularization constant for ridge regression. + */ LogisticRegressionFunction(const MatType& predictors, const arma::Row& responses, const arma::vec& initialPoint, @@ -59,7 +74,7 @@ class LogisticRegressionFunction /** * Evaluate the logistic regression log-likelihood function with the given - * parameters. Note that if a point has 0 probability of being classified + * parameters. Note that if a point has 0 probability of being classified * directly with the given parameters, then Evaluate() will return nan (this * is kind of a corner case and should not happen for reasonable models). * @@ -72,9 +87,9 @@ class LogisticRegressionFunction /** * Evaluate the logistic regression log-likelihood function with the given - * parameters using the given batch size from the given point index. This is + * parameters using the given batch size from the given point index. This is * useful for optimizers such as SGD, which require a separable objective - * function. Note that if the points have 0 probability of being classified + * function. Note that if the points have 0 probability of being classified * correctly with the given parameters, then Evaluate() will return nan (this * is kind of a corner case and should not happen for reasonable models). * @@ -102,8 +117,8 @@ class LogisticRegressionFunction /** * Evaluate the gradient of the logistic regression log-likelihood function - * with the given parameters, for the given batch size from a given point the - * in dataset. This is useful for optimizers such as SGD, which require a + * with the given parameters, for the given batch size from a given point in + * the dataset. This is useful for optimizers such as SGD, which require a * separable objective function. * * @param parameters Vector of logistic regression parameters. @@ -122,7 +137,7 @@ class LogisticRegressionFunction /** * 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 SCD, which require + * dataset. This is useful for optimizers such as SCD, which require * partial gradients. * * @param parameters Vector of logistic regression parameters. @@ -145,7 +160,7 @@ class LogisticRegressionFunction /** * 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 the in dataset. + * the given batch size from a given point in the dataset. */ template double EvaluateWithGradient(const arma::mat& parameters, From 61384ec2a6f87b157003473297a4426515f19d9f Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Thu, 4 Apr 2019 15:06:38 +0530 Subject: [PATCH 3/5] correct styles --- .../logistic_regression/logistic_regression_function.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp index 524beec83b..559043651a 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp @@ -35,7 +35,7 @@ class LogisticRegressionFunction * @param responses y, the measured data for each point in X. * @param lambda Regularization constant for ridge regression. */ - LogisticRegressionFunction(const MatType& predictors, + LogisticRegressionFunction(const MatType& predictors, const arma::Row& responses, const double lambda = 0); From 06037419f806d262f4a6d0189883e7e6256c94a9 Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Thu, 4 Apr 2019 19:17:23 +0530 Subject: [PATCH 4/5] update documentation --- .../logistic_regression_function.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp index 559043651a..653bace31f 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp @@ -31,8 +31,8 @@ class LogisticRegressionFunction /** * Creates the LogisticRegressionFunction. * - * @param predictors X, matrix of data points. - * @param responses y, the measured data for each point in X. + * @param predictors, the matrix of data points. + * @param responses, the measured data for each point in predictors. * @param lambda Regularization constant for ridge regression. */ LogisticRegressionFunction(const MatType& predictors, @@ -42,9 +42,9 @@ class LogisticRegressionFunction /** * Creates the LogisticRegressionFunction with initialPoint. * - * @param predictors X, matrix of data points. - * @param responses y, the measured data for each point in X. - * @param initialPoint from which to start the optimization. + * @param predictors, the matrix of data points. + * @param responses, the measured data for each point in predictors. + * @param initialPoint, point from which to start the optimization. * @param lambda Regularization constant for ridge regression. */ LogisticRegressionFunction(const MatType& predictors, From f89a04fc9ef1855651517f0d1ddc07aacc51a103 Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Fri, 5 Apr 2019 12:57:56 +0530 Subject: [PATCH 5/5] update documentation --- .../logistic_regression_function.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp index 653bace31f..6b8a6a3175 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function.hpp @@ -31,8 +31,8 @@ class LogisticRegressionFunction /** * Creates the LogisticRegressionFunction. * - * @param predictors, the matrix of data points. - * @param responses, the measured data for each point in predictors. + * @param predictors The matrix of data points. + * @param responses The measured data for each point in predictors. * @param lambda Regularization constant for ridge regression. */ LogisticRegressionFunction(const MatType& predictors, @@ -42,9 +42,9 @@ class LogisticRegressionFunction /** * Creates the LogisticRegressionFunction with initialPoint. * - * @param predictors, the matrix of data points. - * @param responses, the measured data for each point in predictors. - * @param initialPoint, point from which to start the optimization. + * @param predictors The matrix of data points. + * @param responses The measured data for each point in predictors. + * @param initialPoint Point from which to start the optimization. * @param lambda Regularization constant for ridge regression. */ LogisticRegressionFunction(const MatType& predictors,