-
-
Save zoq/8a0b2e755412a0ca4e3ce9529e001c7c to your computer and use it in GitHub Desktop.
cat-data.cpp
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
arma::mat dataset; // Load data into this matrix. | |
mlpack::data::DatasetInfo info; // This will store the mappings. | |
// Load the dataset. | |
mlpack::data::Load("test.csv", dataset, info); | |
size_t catDim; | |
// Loop over all features, and add 1 to all non-categorical features. | |
for (size_t i = 0; i < info.Dimensionality(); ++i) | |
{ | |
// The Type() function returns whether or not the data is numeric or | |
// categorical. | |
if (info.Type(i) != mlpack::data::Datatype::categorical) | |
std::cout << dataset.row(i) << std::endl; | |
if (info.Type(i) == mlpack::data::Datatype::categorical) | |
catDim = i; | |
} | |
for (size_t i = 0; i < dataset.n_cols; ++i) | |
std::cout << info.UnmapString(dataset.at(catDim, i), catDim, 0) << std::endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment