powered by
Creates k-fold cross-validation splits of a distance matrix while maintaining symmetry. Each fold has a training matrix with some values masked for validation.
create_cv_folds( truth_matrix, no_noise_truth = NULL, n_folds = 10, random_seed = NULL )
A list of length n_folds. Each element is a list containing two matrices:
n_folds
The truth matrix for that fold.
The training matrix with some values replaced by NA for validation.
NA
Matrix of true distances
Optional matrix of noise-free distances. If provided, used as truth.
Integer number of folds to create
Integer random seed for reproducibility
# Create a sample distance matrix dist_matrix <- matrix(runif(100), 10, 10) diag(dist_matrix) <- 0 # Create 5-fold CV splits folds <- create_cv_folds(dist_matrix, n_folds = 5, random_seed = 123)
Run the code above in your browser using DataLab