56 for (
int rep = 0; rep <
n_repeats; ++rep) {
58 uint64_t rep_seed = seed + rep;
70 explicit Folds(
const std::vector<std::vector<int>>& user_folds)
74 folds.emplace_back(user_folds);
82 explicit Folds(
const std::vector<std::vector<std::vector<int>>>& user_folds)
97 size_t rep_idx = 0)
const;
108 size_t rep_idx = 0)
const;
122 template<
typename MatrixType>
123 std::tuple<MatrixType, Eigen::MatrixXd, MatrixType, Eigen::MatrixXd>
split(
125 const Eigen::MatrixXd& y,
127 size_t rep_idx = 0)
const
132 MatrixType x_test =
subset(x, test_idx);
133 Eigen::MatrixXd y_test = y(test_idx, Eigen::all);
135 MatrixType x_train =
subset(x, train_idx);
136 Eigen::MatrixXd y_train = y(train_idx, Eigen::all);
138 return { x_train, y_train, x_test, y_test };
162 std::vector<std::vector<std::vector<int>>>
182 static std::vector<std::vector<int>> createFolds(
int n_samples,
Manages data partitioning for cross-validation.
std::size_t n_folds
Number of folds.
Folds(const std::vector< std::vector< int > > &user_folds)
Constructor for user-provided folds.
Folds(int n_samples, int n_folds, int n_repeats=1, uint64_t seed=42)
Constructor for generating random folds with optional repetitions.
size_t numEvals() const
Get the total number of folds (repetitions * folds)
size_t numFolds() const
Get the 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.
std::tuple< MatrixType, Eigen::MatrixXd, MatrixType, Eigen::MatrixXd > split(MatrixType &x, const Eigen::MatrixXd &y, size_t fold_idx, size_t rep_idx=0) const
Split data into training and test sets 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.
size_t numRepetitions() const
Get the number of repetitions.
Folds(const std::vector< std::vector< std::vector< int > > > &user_folds)
Constructor for user-provided repeated folds.
Folds()
Default constructor.
std::vector< std::vector< std::vector< int > > > folds
Indices for each fold in each repetition.
std::size_t n_repeats
Number of repetitions.
Namespace containing SLOPE regression implementation.
Eigen::MatrixXd subset(const Eigen::MatrixXd &x, const std::vector< int > &indices)
Extract a subset of rows from an Eigen matrix.
Various utility functions.