13#ifndef MLPACK_METHODS_RANDOM_FOREST_BOOTSTRAP_HPP
14#define MLPACK_METHODS_RANDOM_FOREST_BOOTSTRAP_HPP
22template<
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 for (
size_t i = 0; i < dataset.n_cols; ++i)
43 bootstrapDataset.col(i) = dataset.col(indices[i]);
44 bootstrapLabels[i] = labels[indices[i]];
46 bootstrapWeights[i] = weights[indices[i]];
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.
Linear algebra utility functions, generally performed on matrices or vectors.