Skip to contents

Finding Subgroups with Conformal Trees

Usage

r2p(
  data,
  target,
  learner,
  cv_folds = 10,
  alpha = 0.05,
  gamma = 0.1,
  lambda = 0.5,
  max_groups = 10
)

Arguments

data

(data.frame)
data set for model training and uncertainty estimation.

target

(string)
name of the target variable. The target must be a numeric variable.

learner

(model_spec)
the learner for training the prediction model. See parsnip::model_spec() for details.

cv_folds

(count)
number of CV+ folds.

alpha

(proportion)
miscoverage rate.

gamma

(proportion)
regularization parameter ensuring that reduction in the impurity of the confident homogeneity is sufficiently large.

lambda

(proportion)
balance parameter, quantifying the impact of the average interval length relative to the average absolute deviation (i.e. interval size vs. within-group homogeneity)

max_groups

(count)
maximum number of subgroups.

Value

The tree.

Examples

library(tidymodels)
library(ranger)
data(bikes)
set.seed(1234)
randforest <- rand_forest() %>%
  set_mode("regression") %>%
  set_engine("ranger")
groups <- r2p(
  data = bikes,
  target = "count",
  learner = randforest,
  cv_folds = 10,
  alpha = 0.05,
  gamma = 0.2,
  lambda = 0.5,
  max_groups = 10
)
#> Error in n + 1: non-numeric argument to binary operator
groups$tree
#> Error in groups$tree: object of type 'closure' is not subsettable