Learn R Programming

dtGAP (version 0.0.2)

rf_dtGAP: Visualize a Single Tree from a Conditional Random Forest

Description

Fits a partykit::cforest and visualizes one of its individual trees using the full dtGAP pipeline (decision tree + heatmap + evaluation).

Usage

rf_dtGAP(
  x = NULL,
  target_lab = NULL,
  show = c("all", "train", "test"),
  tree_index = 1L,
  ntree = 500L,
  mtry = NULL,
  rf_control = NULL,
  data_train = NULL,
  data_test = NULL,
  data_all = NULL,
  test_size = 0.3,
  task = c("classification", "regression"),
  trans_type = c("normalize", "scale", "percentize", "none"),
  col_proximity = c("pearson", "spearman", "kendall"),
  linkage_method = c("CT", "SG", "CP"),
  seriate_method = "TSP",
  cRGAR_w = 5,
  sort_by_data_type = TRUE,
  custom_layout = NULL,
  panel_space = 0.001,
  margin = 20,
  total_w = 297,
  total_h = 210,
  tree_p = 0.3,
  include_var_imp = TRUE,
  col_var_imp = "orange",
  var_imp_bar_width = 0.8,
  var_imp_fontsize = 5,
  split_var_bg = "darkgreen",
  split_var_fontsize = 5,
  Col_Prox_palette = "RdBu",
  Col_Prox_n_colors = 11,
  label_map = NULL,
  label_map_colors = NULL,
  type_palette = "Dark2",
  label_palette = "OrRd",
  n_label_color = 9,
  pred_ha_gap = unit(1, "mm"),
  prop_palette = gray,
  n_prop_colors = 11,
  Row_Prox_palette = "Spectral",
  Row_Prox_n_colors = 11,
  row_border = TRUE,
  row_gap = unit(1, "mm"),
  sorted_dat_palette = "Blues",
  sorted_dat_n_colors = 9,
  show_row_names = TRUE,
  row_names_gp = gpar(fontsize = 5),
  show_row_prox = TRUE,
  show_col_prox = TRUE,
  raw_value_col = NULL,
  lgd_direction = c("vertical", "horizontal"),
  x_eval_start = 15,
  y_eval_start = NULL,
  eval_text = 7,
  print_eval = TRUE,
  simple_metrics = FALSE
)

Value

Draws the dtGAP visualization for the selected tree to the current graphics device. Called for its side effect; returns invisibly.

Arguments

x

Character. Name or label of the dataset.

target_lab

Character. Name of the target column.

show

Character. Which subset to show: "all", "train", or "test".

tree_index

Integer. Which tree to extract (1-based). Default is 1.

ntree

Integer. Number of trees in the forest (default 500).

mtry

Integer or NULL. Number of variables randomly sampled at each split. If NULL, uses the cforest default.

rf_control

A ctree_control object or NULL.

data_train

Data frame. Training data.

data_test

Data frame. Test data.

data_all

Data frame. Full dataset.

test_size

Numeric. Proportion for test split (default 0.3).

task

Character. "classification" or "regression".

trans_type

Character. Transformation type.

col_proximity

Character. Correlation method.

linkage_method

Character. Linkage method.

seriate_method

Character. Seriation method.

cRGAR_w

Integer. Window size for RGAR.

sort_by_data_type

Logical. Preserve data_type grouping.

custom_layout

Optional custom node positions.

panel_space

Numeric. Vertical spacing.

margin

Numeric. Margin in mm.

total_w

Numeric. Page width in mm.

total_h

Numeric. Page height in mm.

tree_p

Numeric. Tree panel proportion.

include_var_imp

Logical. Show importance barplot.

col_var_imp

Color for importance bars.

var_imp_bar_width

Numeric. Bar width.

var_imp_fontsize

Numeric. Font size for importance.

split_var_bg

Background for split variable names.

split_var_fontsize

Font size for split variable names.

Col_Prox_palette

Palette for correlation heatmap.

Col_Prox_n_colors

Number of correlation colors.

label_map

Named vector for label mapping.

label_map_colors

Named vector of mapped label colors.

type_palette

Palette for data_type.

label_palette

Palette for labels.

n_label_color

Number of label colors.

pred_ha_gap

Gap between annotations.

prop_palette

Probability gradient palette.

n_prop_colors

Number of probability colors.

Row_Prox_palette

Palette for row proximity.

Row_Prox_n_colors

Number of row proximity colors.

row_border

Draw cell borders.

row_gap

Gap between annotation blocks.

sorted_dat_palette

Palette for heatmap.

sorted_dat_n_colors

Number of heatmap colors.

show_row_names

Show row names.

row_names_gp

Font settings for row names.

show_row_prox

Show row proximity.

show_col_prox

Show column proximity.

raw_value_col

Colors for raw data values.

lgd_direction

Legend direction.

x_eval_start

Eval text x position.

y_eval_start

Eval text y position.

eval_text

Eval text font size.

print_eval

Show evaluation results.

simple_metrics

Use simple metrics.

Examples

Run this code
# \donttest{
rf_dtGAP(
  data_train = train_covid,
  data_test = test_covid,
  target_lab = "Outcome",
  show = "test",
  tree_index = 1,
  ntree = 50,
  print_eval = FALSE
)
# }

Run the code above in your browser using DataLab