[mlpack] 185/207: Set random seed when splitting dataset.
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 52be857b6c25b3ff18da8d8ef5ad545fbd3f830f
Author: Ryan Curtin <ryan at ratml.org>
Date: Fri Mar 17 11:17:39 2017 -0400
Set random seed when splitting dataset.
---
src/mlpack/methods/preprocess/preprocess_split_main.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/mlpack/methods/preprocess/preprocess_split_main.cpp b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
index 036ca17..e0cf277 100644
--- a/src/mlpack/methods/preprocess/preprocess_split_main.cpp
+++ b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
@@ -13,6 +13,8 @@
#include <mlpack/core/data/load.hpp>
#include <mlpack/core/data/save.hpp>
#include <mlpack/core/util/param.hpp>
+#include <mlpack/core/math/random.hpp>
+#include <mlpack/core/util/cli.hpp>
#include <mlpack/core/data/split_data.hpp>
PROGRAM_INFO("Split Data", "This utility takes a dataset and optionally labels "
@@ -60,6 +62,8 @@ PARAM_STRING_OUT("test_labels_file", "File name to save test label", "L");
PARAM_DOUBLE_IN("test_ratio", "Ratio of test set; if not set,"
"the ratio defaults to 0.2", "r", 0.2);
+PARAM_INT_IN("seed", "Random seed (0 for std::time(NULL)).", "s", 0);
+
using namespace mlpack;
using namespace arma;
using namespace std;
@@ -76,6 +80,11 @@ int main(int argc, char** argv)
const string testLabelsFile = CLI::GetParam<string>("test_labels_file");
const double testRatio = CLI::GetParam<double>("test_ratio");
+ if (CLI::GetParam<int>("seed") == 0)
+ math::RandomSeed(std::time(NULL));
+ else
+ math::RandomSeed((size_t) CLI::GetParam<int>("seed"));
+
// Make sure the user specified output filenames.
if (trainingFile == "")
Log::Warn << "--training_file (-t) is not specified; no training set will "
--
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