View source: R/32_KFOLD_INDICES.R

kfold.idx | R Documentation |

`kfold.idx`

provides indices for K-fold validation.

```
kfold.idx(target, k = 10, type, seed = 2191)
```

`target` |
Binary target variable. |

`k` |
Number of folds. If |

`type` |
Sampling type. Possible options are |

`seed` |
Random seed needed for ensuring the result reproducibility. Default is 2191. |

The command `kfold.idx`

returns a list of k folds estimation and validation indices.

```
suppressMessages(library(PDtoolkit))
data(loans)
#good-bad ratio
prop.table(table(loans$Creditability))
#random k-folds
kf.r <- kfold.idx(target = loans$Creditability, k = 5, type = "random", seed = 2191)
lapply(kf.r, function(x) prop.table(table(loans$Creditability[x[[2]]])))
#stratified k-folds
kf.s <- kfold.idx(target = loans$Creditability, k = 5, type = "stratified", seed = 2191)
lapply(kf.s, function(x) prop.table(table(loans$Creditability[x[[2]]])))
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.