[mlpack] 181/207: Add Classify in SoftmaxRegression

Barak A. Pearlmutter barak+git at pearlmutter.net
Thu Mar 23 17:53:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit 11fc169f9b89a5c940800431f5989dbc4dea564f
Author: Kirill Mishchenko <ki.mishchenko at gmail.com>
Date:   Wed Mar 15 08:45:47 2017 +0500

    Add Classify in SoftmaxRegression
---
 .../methods/softmax_regression/softmax_regression.hpp       | 13 +++++++++++++
 .../methods/softmax_regression/softmax_regression_impl.hpp  | 10 +++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/methods/softmax_regression/softmax_regression.hpp b/src/mlpack/methods/softmax_regression/softmax_regression.hpp
index 3712c4a..a62de8f 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression.hpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression.hpp
@@ -113,12 +113,25 @@ class SoftmaxRegression
    * calculates the probabilities for every class, given a data point. It then
    * chooses the class which has the highest probability among all.
    *
+   * This method is deprecated -- you should use Classify() instead.
+   *
    * @param testData Matrix of data points for which predictions are to be made.
    * @param predictions Vector to store the predictions in.
    */
   void Predict(const arma::mat& testData, arma::Row<size_t>& predictions) const;
 
   /**
+   * Classify the given points, returning the predicted labels for each point.
+   * The function calculates the probabilities for every class, given a data
+   * point. It then chooses the class which has the highest probability among
+   * all.
+   *
+   * @param dataset Set of points to classify.
+   * @param labels Predicted labels for each point.
+   */
+  void Classify(const arma::mat& dataset, arma::Row<size_t>& labels) const;
+
+  /**
    * Computes accuracy of the learned model given the feature data and the
    * labels associated with each data point. Predictions are made using the
    * provided data and are compared with the actual labels.
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp b/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp
index c5c8486..0a915f2 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp
@@ -120,6 +120,14 @@ void SoftmaxRegression<OptimizerType>::Predict(const arma::mat& testData,
 }
 
 template<template<typename> class OptimizerType>
+void SoftmaxRegression<OptimizerType>::Classify(const arma::mat& dataset,
+                                                arma::Row<size_t>& labels)
+    const
+{
+  Predict(dataset, labels);
+}
+
+template<template<typename> class OptimizerType>
 double SoftmaxRegression<OptimizerType>::ComputeAccuracy(
     const arma::mat& testData,
     const arma::Row<size_t>& labels) const
@@ -127,7 +135,7 @@ double SoftmaxRegression<OptimizerType>::ComputeAccuracy(
   arma::Row<size_t> predictions;
 
   // Get predictions for the provided data.
-  Predict(testData, predictions);
+  Classify(testData, predictions);
 
   // Increment count for every correctly predicted label.
   size_t count = 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list