10 return folds[rep_idx][fold_idx];
16 std::vector<int> train_indices;
17 for (
size_t i = 0; i <
n_folds; ++i) {
19 const auto& fold =
folds[rep_idx][i];
20 train_indices.insert(train_indices.end(), fold.begin(), fold.end());
26std::vector<std::vector<int>>
27Folds::createFolds(
int n,
int n_folds, uint64_t random_seed)
30 std::mt19937 generator(random_seed);
33 std::vector<int> indices(n);
34 std::iota(indices.begin(), indices.end(), 0);
35 std::shuffle(indices.begin(), indices.end(), generator);
41 int base_fold_size = n /
n_folds;
48 for (
int fold = 0; fold <
n_folds; ++fold) {
50 int fold_size = base_fold_size + (fold < remainder ? 1 : 0);
53 folds[fold].reserve(fold_size);
54 for (
int i = 0; i < fold_size; ++i) {
55 folds[fold].push_back(indices[current_pos++]);
std::size_t n_folds
Number of folds.
std::vector< int > getTrainingIndices(size_t fold_idx, size_t rep_idx=0) const
Get training indices for a specific fold and repetition.
const std::vector< int > & getTestIndices(size_t fold_idx, size_t rep_idx=0) const
Get test indices for a specific fold and repetition.
std::vector< std::vector< std::vector< int > > > folds
Indices for each fold in each repetition.
Cross-validation fold management for SLOPE models.
Namespace containing SLOPE regression implementation.