View source: R/070_Hyperparameters.R
| setup_Ranger | R Documentation |
Setup hyperparameters for Ranger Random Forest training.
setup_Ranger(
num_trees = 500L,
mtry = NULL,
importance = "impurity",
write_forest = TRUE,
probability = FALSE,
min_node_size = NULL,
min_bucket = NULL,
max_depth = NULL,
replace = TRUE,
sample_fraction = ifelse(replace, 1, 0.632),
class_weights = NULL,
splitrule = NULL,
num_random_splits = 1L,
alpha = 0.5,
minprop = 0.1,
poisson_tau = 1,
split_select_weights = NULL,
always_split_variables = NULL,
respect_unordered_factors = NULL,
scale_permutation_importance = FALSE,
local_importance = FALSE,
regularization_factor = 1,
regularization_usedepth = FALSE,
keep_inbag = FALSE,
inbag = NULL,
holdout = FALSE,
quantreg = FALSE,
time_interest = NULL,
oob_error = TRUE,
save_memory = FALSE,
verbose = TRUE,
node_stats = FALSE,
seed = NULL,
na_action = "na.learn",
ifw = FALSE
)
num_trees |
(Tunable) Integer [1, Inf): Number of trees. |
mtry |
(Tunable) Optional Integer [1, Inf): Number of features to consider at each split. |
importance |
Character {"none", "impurity", "impurity_corrected", "permutation"}: Variable importance mode. "impurity" is the Gini index for classification, the response variance for regression. |
write_forest |
Logical: If TRUE, save the forest object (required for prediction). Set to FALSE to reduce memory if no prediction is intended. |
probability |
Logical: If TRUE, grow a probability forest. Classification only. |
min_node_size |
(Tunable) Optional Integer [1, Inf): Minimal node size. If NULL, ranger uses 1 for classification, 5 for regression, 3 for survival, and 10 for probability. |
min_bucket |
Optional Integer [1, Inf): Fewest cases a terminal node may hold; no split creates a smaller node. Unset uses ranger's default of 1. |
max_depth |
(Tunable) Optional Integer [0, Inf): Maximal tree depth. NULL or 0 means unlimited depth, 1 means tree stumps. |
replace |
(Tunable) Logical: If TRUE, sample with replacement. |
sample_fraction |
(Tunable) Numeric (0, 1]: Fraction of observations to sample. Default is 1 with replacement and 0.632 without. |
class_weights |
Optional Numeric [0, Inf) vector: Per-class weights for classification. Length equal to the number of classes, named by class label. NULL weights every class equally. |
splitrule |
(Tunable) Optional Character: Splitting rule. Classification: "gini", "extratrees", "hellinger"; regression: "variance", "extratrees", "maxstat", "beta"; survival: "logrank", "extratrees", "C", "maxstat". |
num_random_splits |
(Tunable) Integer [1, Inf): Number of random splits per candidate variable, for the "extratrees" splitrule. |
alpha |
(Tunable) Numeric [0, 1]: Significance threshold to allow splitting, for the "maxstat" splitrule. |
minprop |
(Tunable) Numeric [0, 1]: Lower quantile of the covariate distribution considered for splitting, for the "maxstat" splitrule. |
poisson_tau |
Numeric (0, Inf): Tau parameter, for the "poisson" regression splitrule. |
split_select_weights |
Optional List: Per-feature probabilities of being selected for splitting, in [0, 1]. One vector applied to every tree, or a list of length |
always_split_variables |
Optional Character vector: Names of variables to always include as split candidates, in addition to the |
respect_unordered_factors |
Optional Character {"partition", "ignore", "order"}: Handling of unordered factors. "partition" considers all 2-partitions, "ignore" orders levels by first occurrence, "order" orders levels by mean response. |
scale_permutation_importance |
Logical: If TRUE, scale permutation importance by its standard error. Permutation importance only. |
local_importance |
Logical: If TRUE, compute local (per-observation) permutation importance. |
regularization_factor |
(Tunable) Numeric [0, Inf): Regularization factor penalizing variables with many split points. Requires |
regularization_usedepth |
Logical: If TRUE, apply the regularization factor with node depth. Requires |
keep_inbag |
Logical: If TRUE, record how often each observation is in-bag per tree. |
inbag |
Optional List: Manually set in-bag counts; a list of length |
holdout |
Logical: If TRUE, use hold-out mode: hold out samples with case weight 0 and use them for variable importance and prediction error. |
quantreg |
Logical: If TRUE, prepare quantile prediction (quantile regression forests). Regression only; set |
time_interest |
Optional Numeric vector: Time points of interest for survival prediction. Survival only. NULL uses the observed event times. |
oob_error |
Logical: If TRUE, compute the OOB prediction error. Set to FALSE to save time if only the forest is needed. |
save_memory |
Logical: If TRUE, use the memory-saving (slower) splitting mode. Use only if you encounter memory problems. |
verbose |
Logical: If TRUE, show computation status and estimated runtime. |
node_stats |
Logical: If TRUE, save additional node statistics (terminal nodes only). |
seed |
Optional Integer: Random seed. If NULL, the seed is generated from R. Set to 0 to ignore the R seed. |
na_action |
Character {"na.learn", "na.omit", "na.fail"}: How to handle missing values. "na.learn" uses observations with missing values in splitting, treating missing as a separate category. |
ifw |
(Tunable) Logical: If TRUE, use Inverse Frequency Weighting in classification. |
Get more information from ranger::ranger.
RangerHyperparameters object.
EDG
ranger_hyperparams <- setup_Ranger(num_trees = 1000L, ifw = FALSE)
ranger_hyperparams
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.