13 #ifndef MLPACK_METHODS_RANDOM_FOREST_BOOTSTRAP_HPP 14 #define MLPACK_METHODS_RANDOM_FOREST_BOOTSTRAP_HPP 22 template<
bool UseWeights,
27 const LabelsType& labels,
28 const WeightsType& weights,
29 MatType& bootstrapDataset,
30 LabelsType& bootstrapLabels,
31 WeightsType& bootstrapWeights)
33 bootstrapDataset.set_size(dataset.n_rows, dataset.n_cols);
34 bootstrapLabels.set_size(labels.n_elem);
36 bootstrapWeights.set_size(weights.n_elem);
39 arma::uvec indices = arma::randi<arma::uvec>(dataset.n_cols,
40 arma::distr_param(0, dataset.n_cols - 1));
41 bootstrapDataset = dataset.cols(indices);
42 bootstrapLabels = labels.cols(indices);
44 bootstrapWeights = weights.cols(indices);
Linear algebra utility functions, generally performed on matrices or vectors.
void Bootstrap(const MatType &dataset, const LabelsType &labels, const WeightsType &weights, MatType &bootstrapDataset, LabelsType &bootstrapLabels, WeightsType &bootstrapWeights)
Given a dataset, create another dataset via bootstrap sampling, with labels.