Description Usage Arguments Value Note References See Also Examples
This method create the kFoldPartition object, from it is possible create the dataset partitions to train, test and optionally to validation.
1 2 3 4 5 | create_kfold_partition(
mdata,
k = 10,
method = c("random", "iterative", "stratified")
)
|
mdata |
A mldr dataset. |
k |
The number of desirable folds. (Default: 10) |
method |
The method to split the data. The default methods are:
You can also create your own partition method. See the note and example sections to more details. (Default: "random") |
An object of type kFoldPartition.
To create your own split method, you need to build a function that receive a mldr object and a list with the proportions of examples in each fold and return an other list with the index of the elements for each fold.
Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the stratification of multi-label data. In Proceedings of the Machine Learning and Knowledge Discovery in Databases - European Conference, ECML PKDD (pp. 145-158).
How to create the datasets from folds
Other sampling:
create_holdout_partition()
,
create_random_subset()
,
create_subset()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | k10 <- create_kfold_partition(toyml, 10)
k5 <- create_kfold_partition(toyml, 5, "stratified")
sequencial_split <- function (mdata, r) {
S <- list()
amount <- trunc(r * mdata$measures$num.instances)
indexes <- c(0, cumsum(amount))
indexes[length(r)+1] <- mdata$measures$num.instances
S <- lapply(seq(length(r)), function (i) {
seq(indexes[i]+1, indexes[i+1])
})
S
}
k3 <- create_kfold_partition(toyml, 3, "sequencial_split")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.