caretRFRepeatedCV: Random Forest with Repeated Cross Validation

View source: R/caretRFRepeatedCV.R

caretRFRepeatedCVR Documentation

Random Forest with Repeated Cross Validation

Description

Random Forest with Repeated Cross Validation

Arguments

x

Phyloseq object with sample_data and otu_table

features

Features to use for RF model.

sample_group

Variable in sample_data to test for differences in taxa abundances

folds

Repeated hold-out to apply. Default is '5'

repeats

Number of repeats. Default is '100'

seed

Variable in sample_data to test for differences in taxa abundances

metric

See train. Default is 'Accuracy'

print_final

Logical. Default is TRUE. Prints the final model output

...

Additional arguments passed on to train.

Details

Performs a Random forest with repeated Cross-validation. The function as the name suggests uses caret under the hood. Make sure to cite the original caret package with correct version number.

Value

A list is returned of class train. See train

Author(s)

Sudarshan A. Shetty

See Also

train

Examples


library(biomeStats)
library(microbiome)
library(biomeUtils)
ps <- FuentesIliGutData |>
             microbiome::transform("compositional") |>
             biomeUtils::mutateTaxaTable(FeatureID = taxa_names(FuentesIliGutData)) |>
             biomeUtils::filterSampleData(ILI != "L2")
# select features reduced for speed in example
features.to.use <- core_members(ps, 0.01, 25/100)

# for example reduce folds and repeats
rf.fit <- caretRFRepeatedCV(ps,
                            sample_group = "ILI",
                            features = features.to.use,
                            folds = 3,
                            repeats = 5,
                            set.seed = 1819,
                            metric = "Accuracy",
                            print_final=TRUE)
print(rf.fit)
#Check splits for each fold
#table(rf.fit$pred$Resample, rf.fit$pred$obs)


RIVM-IIV-Microbiome/biomeStats documentation built on Sept. 14, 2022, 5:15 p.m.