get_factor_split_levels: Get split criterion (levels) for factor or character...

View source: R/get_factor_split_levels.R

get_factor_split_levelsR Documentation

Get split criterion (levels) for factor or character variables Character variables are automatically turned into factors in function ranger() from the package "ranger" Considers the three possibilities to treat and split factors (Parameter "respect.unordered.factors" in ranger()): - Treat the factor like an ordinal variable ("none", "NULL" or "FALSE" in ranger()) - Treat the factor as nominal and check all 2-partitions for split ("partition") - Treat factor as ordinal and determine optimal order of levels for the random forest ("order", "TRUE" in ranger())

Description

Get split criterion (levels) for factor or character variables Character variables are automatically turned into factors in function ranger() from the package "ranger" Considers the three possibilities to treat and split factors (Parameter "respect.unordered.factors" in ranger()): - Treat the factor like an ordinal variable ("none", "NULL" or "FALSE" in ranger()) - Treat the factor as nominal and check all 2-partitions for split ("partition") - Treat factor as ordinal and determine optimal order of levels for the random forest ("order", "TRUE" in ranger())

Usage

get_factor_split_levels(
  node_id,
  split_variable,
  split_variable_type,
  split_value,
  train_data_df,
  rf_list
)

Arguments

node_id

Node ID of the node whose parent ID is to be determined

split_variable

Column name of the split variable in training data

split_variable_type

Type of split variable: "factor" for factors, "character" for character variable

split_value

Number(s) used for the split, for example the entry "splival" from the function treeInfo()

train_data_df

Data frame of the training data with which the random forest was trained

rf_list

Random forest, which is built like the one you get from ranger()

Value

Character with levels passed from the parent node to the considered node

Author(s)

Lea Louisa Kronziel, M.Sc.


imbs-hl/timbR documentation built on April 17, 2025, 2:08 p.m.