View source: R/mm4_format_nfold.R
format_nfold | R Documentation |
The format_nfold
function takes a data frame with scores, label,
and n-fold columns and convert it to a list for evalmod
and mmdata
.
format_nfold(nfold_df, score_cols, lab_col, fold_col)
nfold_df |
A data frame that contains at least one score column, label and fold columns. |
score_cols |
A character/numeric vector that specifies score columns
of |
lab_col |
A number/string that specifies the label column
of |
fold_col |
A number/string that specifies the fold column
of |
The format_nfold
function returns a list that
contains multiple scores and labels.
evalmod
for calculation evaluation measures.
mmdata
for formatting input data.
join_scores
and join_labels
for formatting
scores and labels with multiple datasets.
##################################################
### Convert dataframe with 2 models and 5-fold datasets
###
## Load test data
data(M2N50F5)
head(M2N50F5)
## Convert with format_nfold
nfold_list1 <- format_nfold(
nfold_df = M2N50F5, score_cols = c(1, 2),
lab_col = 3, fold_col = 4
)
## Show the list structure
str(nfold_list1)
str(nfold_list1$scores)
str(nfold_list1$labels)
##################################################
### Speficy a single score column
###
## Convert with format_nfold
nfold_list2 <- format_nfold(
nfold_df = M2N50F5, score_cols = 1,
lab_col = 3, fold_col = 4
)
## Show the list structure
str(nfold_list2)
str(nfold_list2$scores)
str(nfold_list2$labels)
##################################################
### Use column names
###
## Convert with format_nfold
nfold_list3 <- format_nfold(
nfold_df = M2N50F5,
score_cols = c("score1", "score2"),
lab_col = "label", fold_col = "fold"
)
## Show the list structure
str(nfold_list3)
str(nfold_list3$scores)
str(nfold_list3$labels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.