create_cv_folds | R Documentation |
Creates k-fold cross-validation splits from a dissimilarity matrix while maintaining
symmetry. Each fold in the output consists of a training matrix (with some
values masked as NA
) and a corresponding ground truth matrix for validation.
create_cv_folds(
dissimilarity_matrix,
ground_truth_matrix = NULL,
n_folds = 10,
random_seed = NULL
)
dissimilarity_matrix |
The input dissimilarity matrix, which may contain noise. |
ground_truth_matrix |
An optional, noise-free dissimilarity matrix to be used as the ground truth for evaluation. If |
n_folds |
The integer number of folds to create. |
random_seed |
An optional integer to set the random seed for reproducibility. |
A list of length n_folds
. Each element of the list is itself a list
containing two matrices: truth
(the ground truth for that fold) and train
(the training matrix with NA
values for validation).
This function has breaking changes from previous versions:
Parameter truth_matrix
renamed to dissimilarity_matrix
Parameter no_noise_truth
renamed to ground_truth_matrix
Return structure now uses named elements ($truth
, $train
)
# Create a sample dissimilarity matrix
d_mat <- matrix(runif(100), 10, 10)
diag(d_mat) <- 0
# Create 5-fold cross-validation splits
folds <- create_cv_folds(d_mat, n_folds = 5, random_seed = 123)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.