Learn R Programming

RFmarkerDetector (version 1.0.1)

tuneMTRY: Tuning of the mtry parameter for a Random Forest model

Description

tuneMTRY tries to identify the 'optimal' value of the mtry parameter which indicates the number of input variables randomly chosen at each node

Usage

tuneMTRY(data, iterations, maxntree, mtry_length, changeTreeNum = F, graph = T)

Arguments

data
the n x p dataframe used to build the models and to tune the parameter mtry. The first two columns must represent respectively the sample names and the class labels related to each sample
iterations
the number of different random forest models built for each value of mtry
maxntree
the maximum number of trees of each random forest model
mtry_length
an integer value representing the number of mtry values to test.
changeTreeNum
a logical value indicating whether or not to change
graph
a logical value indicating whether to plot the OOB error as a function of the parameter mtry the number of trees during the tuning of mtry

Value

a list of two elements:
  • a diagram of the average value of the OOB error as a function of the mtry with its 95% confidence interval
  • a n x p matrix of n iterations and p mtry values tested

Details

The function searches for the optimal value of mtry assigning to it a set of values and building different random forests (also with a different number of trees) for each value of the mtry. The number of models built for each mtry is defined by the iteration parameter. The oob errors of each random forest model, computed for each mtry value, are then arranged in a matrix

Examples

Run this code
## data(cachexiaData)
## res <- tuneMTRY(cachexiaData, iterations = 10, maxntree = 600, mtry_length = 10, graph = FALSE)

Run the code above in your browser using DataLab