[mlpack-git] master: rename TrainTestSplit to Split (c8a60b2)

gitdub at mlpack.org gitdub at mlpack.org
Thu May 26 15:32:39 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/e3a23c256f017ebb8185b15847c82f51d359cdfd...181792d99549467440b2b839f52deec75be10334

>---------------------------------------------------------------

commit c8a60b2db341eab52927bb0707dfc3976e437c8b
Author: Keon Kim <kwk236 at gmail.com>
Date:   Fri May 27 04:32:39 2016 +0900

    rename TrainTestSplit to Split


>---------------------------------------------------------------

c8a60b2db341eab52927bb0707dfc3976e437c8b
 src/mlpack/core/data/split_data.hpp                | 38 +++++++++++-----------
 .../methods/preprocess/preprocess_split_main.cpp   |  2 +-
 src/mlpack/tests/split_data_test.cpp               |  6 ++--
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/mlpack/core/data/split_data.hpp b/src/mlpack/core/data/split_data.hpp
index b2af0c2..3811320 100644
--- a/src/mlpack/core/data/split_data.hpp
+++ b/src/mlpack/core/data/split_data.hpp
@@ -2,7 +2,7 @@
  * @file split_data.hpp
  * @author Tham Ngap Wei, Keon Kim
  *
- * Defines TrainTestSplit() and LabelTrainTestSplit(), utility functions to split a dataset into a
+ * Defines Split(), a utility function to split a dataset into a
  * training set and a test set.
  */
 #ifndef MLPACK_CORE_UTIL_SPLIT_DATA_HPP
@@ -28,7 +28,7 @@ namespace data {
  *
  * // Split the dataset into a training and test set, with 30% of the data being
  * // held out for the test set.
- * LabelTrainTestSplit(input, label, trainData,
+ * Split(input, label, trainData,
  *                testData, trainLabel, testLabel, 0.3);
  * @endcode
  *
@@ -41,13 +41,13 @@ namespace data {
  * @param testRatio Percentage of dataset to use for test set (between 0 and 1).
  */
 template<typename T, typename U>
-void LabelTrainTestSplit(const arma::Mat<T>& input,
-                         const arma::Row<U>& inputLabel,
-                         arma::Mat<T>& trainData,
-                         arma::Mat<T>& testData,
-                         arma::Row<U>& trainLabel,
-                         arma::Row<U>& testLabel,
-                         const double testRatio)
+void Split(const arma::Mat<T>& input,
+                    const arma::Row<U>& inputLabel,
+                    arma::Mat<T>& trainData,
+                    arma::Mat<T>& testData,
+                    arma::Row<U>& trainLabel,
+                    arma::Row<U>& testLabel,
+                    const double testRatio)
 {
   const size_t testSize = static_cast<size_t>(input.n_cols * testRatio);
   const size_t trainSize = input.n_cols - testSize;
@@ -86,7 +86,7 @@ void LabelTrainTestSplit(const arma::Mat<T>& input,
  *
  * // Split the dataset into a training and test set, with 30% of the data being
  * // held out for the test set.
- * TrainTestSplit(input, trainData, testData, 0.3);
+ * Split(input, trainData, testData, 0.3);
  * @endcode
  *
  * @param input Input dataset to split.
@@ -95,7 +95,7 @@ void LabelTrainTestSplit(const arma::Mat<T>& input,
  * @param testRatio Percentage of dataset to use for test set (between 0 and 1).
  */
 template<typename T>
-void TrainTestSplit(const arma::Mat<T>& input,
+void Split(const arma::Mat<T>& input,
                     arma::Mat<T>& trainData,
                     arma::Mat<T>& testData,
                     const double testRatio)
@@ -129,7 +129,7 @@ void TrainTestSplit(const arma::Mat<T>& input,
  * @code
  * arma::mat input = loadData();
  * arma::Row<size_t> label = loadLabel();
- * auto splitResult = LabelTrainTestSplit(input, label, 0.2);
+ * auto splitResult = Split(input, label, 0.2);
  * @endcode
  *
  * @param input Input dataset to split.
@@ -140,16 +140,16 @@ void TrainTestSplit(const arma::Mat<T>& input,
  */
 template<typename T,typename U>
 std::tuple<arma::Mat<T>, arma::Mat<T>, arma::Row<U>, arma::Row<U>>
-LabelTrainTestSplit(const arma::Mat<T>& input,
-                    const arma::Row<U>& inputLabel,
-                    const double testRatio)
+Split(const arma::Mat<T>& input,
+               const arma::Row<U>& inputLabel,
+               const double testRatio)
 {
   arma::Mat<T> trainData;
   arma::Mat<T> testData;
   arma::Row<U> trainLabel;
   arma::Row<U> testLabel;
 
-  LabelTrainTestSplit(input, inputLabel, trainData, testData, trainLabel, testLabel,
+  Split(input, inputLabel, trainData, testData, trainLabel, testLabel,
       testRatio);
 
   return std::make_tuple(trainData, testData, trainLabel, testLabel);
@@ -163,7 +163,7 @@ LabelTrainTestSplit(const arma::Mat<T>& input,
  *
  * @code
  * arma::mat input = loadData();
- * auto splitResult = TrainTestSplit(input, 0.2);
+ * auto splitResult = Split(input, 0.2);
  * @endcode
  *
  * @param input Input dataset to split.
@@ -173,12 +173,12 @@ LabelTrainTestSplit(const arma::Mat<T>& input,
  */
 template<typename T>
 std::tuple<arma::Mat<T>, arma::Mat<T>>
-TrainTestSplit(const arma::Mat<T>& input,
+Split(const arma::Mat<T>& input,
                const double testRatio)
 {
   arma::Mat<T> trainData;
   arma::Mat<T> testData;
-  TrainTestSplit(input, trainData, testData, testRatio);
+  Split(input, trainData, testData, testRatio);
 
   return std::make_tuple(trainData, testData);
 }
diff --git a/src/mlpack/methods/preprocess/preprocess_split_main.cpp b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
index d6ffb89..dfd79cf 100644
--- a/src/mlpack/methods/preprocess/preprocess_split_main.cpp
+++ b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
@@ -50,7 +50,7 @@ int main(int argc, char** argv)
   arma::rowvec labels_row = labels.row(0); // extract first row
 
   // Split Data
-  const auto value = data::LabelTrainTestSplit(data, labels_row, testRatio);
+  const auto value = data::Split(data, labels_row, testRatio);
   Log::Info << "Train Data Count: " << get<0>(value).n_cols << endl;
   Log::Info << "Test Data Count: " << get<1>(value).n_cols << endl;
   Log::Info << "Train Label Count: " << get<2>(value).n_cols << endl;
diff --git a/src/mlpack/tests/split_data_test.cpp b/src/mlpack/tests/split_data_test.cpp
index 462708e..700e31a 100644
--- a/src/mlpack/tests/split_data_test.cpp
+++ b/src/mlpack/tests/split_data_test.cpp
@@ -73,11 +73,11 @@ BOOST_AUTO_TEST_CASE(SplitDataSplitResultMat)
   input.randu();
 
   // Set the labels to the column ID, so that CompareData can compare the data
-  // after LabelTrainTestSplit is called.
+  // after Split is called.
   const Row<size_t> labels = arma::linspace<Row<size_t>>(0, input.n_cols - 1,
       input.n_cols);
 
-  const auto value = LabelTrainTestSplit(input, labels, 0.2);
+  const auto value = Split(input, labels, 0.2);
   BOOST_REQUIRE_EQUAL(std::get<0>(value).n_cols, 8);
   BOOST_REQUIRE_EQUAL(std::get<1>(value).n_cols, 2);
   BOOST_REQUIRE_EQUAL(std::get<2>(value).n_cols, 8);
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(SplitDataLargerTest)
   const Row<size_t> labels = arma::linspace<Row<size_t>>(0, input.n_cols - 1,
       input.n_cols);
 
-  const auto value = LabelTrainTestSplit(input, labels, 0.3);
+  const auto value = Split(input, labels, 0.3);
   BOOST_REQUIRE_EQUAL(std::get<0>(value).n_cols, 497 - size_t(0.3 * 497));
   BOOST_REQUIRE_EQUAL(std::get<1>(value).n_cols, size_t(0.3 * 497));
   BOOST_REQUIRE_EQUAL(std::get<2>(value).n_cols, 497 - size_t(0.3 * 497));




More information about the mlpack-git mailing list