cv: Multi-label cross-validation

Description Usage Arguments Value See Also Examples

View source: R/cross_validation.R

Description

Perform the cross validation procedure for multi-label learning.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cv(
  mdata,
  method,
  ...,
  cv.folds = 10,
  cv.sampling = c("random", "iterative", "stratified"),
  cv.results = FALSE,
  cv.predictions = FALSE,
  cv.measures = "all",
  cv.cores = getOption("utiml.cores", 1),
  cv.seed = getOption("utiml.seed", NA)
)

Arguments

mdata

A mldr dataset.

method

The multi-label classification method. It also accepts the name of the method as a string.

...

Additional parameters required by the method.

cv.folds

Number of folds. (Default: 10)

cv.sampling

The method to split the data. The default methods are:

random

Split randomly the folds.

iterative

Split the folds considering the labels proportions individually. Some specific label can not occurs in all folds.

stratified

Split the folds considering the labelset proportions.

(Default: "random")

cv.results

Logical value indicating if the folds results should be reported (Default: FALSE).

cv.predictions

Logical value indicating if the predictions should be reported (Default: FALSE).

cv.measures

The measures names to be computed. Call multilabel_measures() to see the expected measures. You can also use "bipartition", "ranking", "label-based", "example-based", "macro-based", "micro-based" and "label-problem" to include a set of measures. (Default: "all").

cv.cores

The number of cores to parallelize the cross validation procedure. (Default: options("utiml.cores", 1))

cv.seed

An optional integer used to set the seed. (Default: options("utiml.seed", NA))

Value

If cv.results and cv.prediction are FALSE, the return is a vector with the expected multi-label measures, otherwise, a list contained the multi-label and the other expected results (the label measures and/or the prediction object) for each fold.

See Also

Other evaluation: multilabel_confusion_matrix(), multilabel_evaluate(), multilabel_measures()

Examples

1
2
3
4
5
6
#Run 10 folds for BR method
res1 <- cv(toyml, br, base.algorithm="RANDOM", cv.folds=10)

#Run 3 folds for RAkEL method and get the fold results and the prediction
res2 <- cv(mdata=toyml, method="rakel", base.algorithm="RANDOM", k=2, m=10,
 cv.folds=3, cv.results=TRUE, cv.predictions=TRUE)

Example output

Loading required package: mldr
Loading required package: parallel
Loading required package: ROCR
Loading required package: gplots

Attaching package: 'gplots'

The following object is masked from 'package:stats':

    lowess

utiml documentation built on May 31, 2021, 9:09 a.m.