Last active
May 26, 2016 18:06
-
-
Save keon/0f7abbd191dbd819a1a5e65caa7954eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load Data and Labels in double types | |
data::Load(inputFile, data, true); | |
data::Load(inputLabel, labels, true); | |
arma::rowvec labels_row = labels.row(0); // extract first row | |
// Split Data | |
const auto value = data::TrainTestSplit(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; | |
Log::Info << "Test Label Count: " << get<3>(value).n_cols << endl; | |
// This is what I am trying to do: (of course the code doesn't work because armadillo does not support string type) | |
// Cast double matrix to string matrix, conv_to reference here -> (http://arma.sourceforge.net/docs.html#conv_to) | |
Mat<string> training = arma::conv_to<Mat<string>>::from(get<0>(value)); | |
Mat<string> test = arma::conv_to<Mat<string>>::from(get<1>(value)); | |
Mat<string> trainingLabels = arma::conv_to<Mat<string>>::from(get<2>(value)); | |
Mat<string> testLabels = arma::conv_to<Mat<string>>::from(get<3>(value)); | |
data::Save(trainingFile, training, false); | |
data::Save(testFile, test, false); | |
data::Save(trainingLabelsFile, trainingLabels, false); | |
data::Save(testLabelsFile, testLabels, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment