format_nfold: Create n-fold cross validation dataset from data frame

Description Usage Arguments Value See Also Examples

View source: R/mm4_format_nfold.R

Description

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.

Usage

1
format_nfold(nfold_df, score_cols, lab_col, fold_col)

Arguments

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 nfold_df.

lab_col

A number/string that specifies the label column of nfold_df.

fold_col

A number/string that specifies the fold column of nfold_df.

Value

The format_nfold function returns a list that contains multiple scores and labels.

See Also

evalmod for calculation evaluation measures. mmdata for formatting input data. join_scores and join_labels for formatting scores and labels with multiple datasets.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
##################################################
### 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)

takayasaito/precrec documentation built on Aug. 24, 2017, 8:07 a.m.