createDataPartition {deforestable} | R Documentation |
As input data, the functions need two folders- Nonforestdir with images of non-forest and forestdir with ones of forest. createDataPartition() splits data into training and testing partitions while keeping the relative sample size of the classes the same as in the original data. createFolds() splits the data into k folds for cross-validation.
createDataPartition(forestdir, Nonforestdir, times = 1, p = 0.5)
createFolds(forestdir, Nonforestdir, k = 5)
forestdir |
path to the directory with (only) forest images |
Nonforestdir |
path to the directory with (only) non-forest images |
times |
the number of data partitions to make |
p |
the percentage of data to set aside for training |
k |
the number of folds to split the data into |
createDataPartition returns a list of data partitions. Each partition consists of 4 sets- forest training, non-forest training, forest test and non-forest test set. createFolds returns lists $forest and $nonforest with k folds in each of them.
createFolds
: Split data into folds
library(deforestable)
forestdir <- system.file('extdata/Forest/', package = "deforestable")
Nonforestdir <- system.file('extdata/Non-forest/', package = "deforestable")
trainPart <- createDataPartition(forestdir=forestdir, Nonforestdir=Nonforestdir, p = .7, times = 1)
folds <- createFolds(forestdir, Nonforestdir, k = 10)