11 #ifndef MLPACK_TESTS_MOCK_CATEGORICAL_DATA_HPP 12 #define MLPACK_TESTS_MOCK_CATEGORICAL_DATA_HPP 29 for (
size_t i = 0; i < 5; ++i)
31 std::vector<arma::vec> probs;
32 probs.push_back(arma::vec(4, arma::fill::randu));
37 for (
size_t i = 0; i < 5; ++i)
39 std::vector<arma::vec> probs;
40 probs.push_back(arma::vec(2, arma::fill::randu));
44 arma::mat spiralDataset(4, 4000);
45 arma::Row<size_t> labels(4000);
46 for (
size_t i = 0; i < 4000; ++i)
49 const double magnitude = 2.0 + (double(i) / 200.0) +
53 const double x = magnitude * cos(angle);
54 const double y = magnitude * sin(angle);
56 spiralDataset(0, i) = x;
57 spiralDataset(1, i) = y;
62 spiralDataset(2, i) = c1[1].
Random()[0];
63 spiralDataset(3, i) = c2[1].
Random()[0];
68 spiralDataset(2, i) = c1[3].
Random()[0];
69 spiralDataset(3, i) = c2[3].
Random()[0];
74 spiralDataset(2, i) = c1[2].
Random()[0];
75 spiralDataset(3, i) = c2[2].
Random()[0];
80 spiralDataset(2, i) = c1[0].
Random()[0];
81 spiralDataset(3, i) = c2[0].
Random()[0];
86 spiralDataset(2, i) = c1[4].
Random()[0];
87 spiralDataset(3, i) = c2[4].
Random()[0];
105 arma::uvec indices = arma::shuffle(arma::linspace<arma::uvec>(0, 3999,
107 d = arma::mat(4, 4000);
108 l = arma::Row<size_t>(4000);
109 for (
size_t i = 0; i < 4000; ++i)
111 d.col(i) = spiralDataset.col(indices[i]);
112 l[i] = labels[indices[i]];
120 arma::Row<double>& l,
127 for (
size_t i = 0; i < 4000; ++i)
140 std::map<int, double> f;
144 std::map<int, double> g;
155 l[i] = d(0, i) + d(1, i) + 3 * d(2, i) + f[(int) d(3, i)] +
156 g[(int) d(4, i)] + noise;
T MapString(const InputType &input, const size_t dimension)
Given the input and the dimension to which it belongs, return its numeric mapping.
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
A discrete distribution where the only observations are discrete observations.
The core includes that mlpack expects; standard C++ includes and Armadillo.
arma::vec Random() const
Return a randomly generated observation (one-dimensional vector; one observation) according to the pr...
Datatype Type(const size_t dimension) const
Return the type of a given dimension (numeric or categorical).
void MockCategoricalData(arma::mat &d, arma::Row< size_t > &l, mlpack::data::DatasetInfo &datasetInfo)
Create a mock categorical dataset for testing classification.
DatasetMapper< data::IncrementPolicy > DatasetInfo
double Random()
Generates a uniform random number between 0 and 1.
int RandInt(const int hiExclusive)
Generates a uniform random integer.