Getting Started with figsr

Introduction to FIGS

figsr implements Fast Interpretable Greedy-Tree Sums (‘FIGS’) (Tan et al., PNAS 2023). FIGS fits a sum of shallow decision trees (\(\hat{f}(x) = \sum_k \hat{f}_k(x)\)) by greedily minimizing residual impurity.


Basic Usage

library(figsr)

set.seed(42)
df <- data.frame(
  x1 = rnorm(100),
  x2 = rnorm(100),
  y = 3 * (rnorm(100) > 0) + rnorm(100, sd = 0.2)
)

fit <- figs(y ~ x1 + x2, data = df, max_splits = 4)
print(fit)
#> ========================================================
#>   FIGS: Fast Interpretable Greedy-Tree Sums Model
#> ========================================================
#> Mode              : regression
#> Total Trees       : 2
#> Total Splits      : 4 / 4 (max_splits)
#> Predictors Used   : x1, x2
#> ========================================================
#> 
#> Use `summary(fit)` to display detailed decision rules.
#> Use `plot(fit)` to visualize decision tree structures.
summary(fit)
#> ========================================================
#>   FIGS Model Summary: Tree Sum Decision Rules
#> ========================================================
#> 
#> --- Tree 1 ---
#>   |-- IF x1 <= 0.930
#>   |   `-- Leaf Value: +1.6150
#>   `-- IF x1 >  0.930
#>      |-- IF x1 <= 1.512
#>      |   `-- Leaf Value: -0.4124
#>      `-- IF x1 >  1.512
#>         `-- Leaf Value: +1.0721
#> 
#> --- Tree 2 ---
#>   |-- IF x1 <= 0.695
#>   |   |-- IF x1 <= -1.697
#>   |   |   `-- Leaf Value: -0.7460
#>   |   `-- IF x1 >  -1.697
#>   |      `-- Leaf Value: +0.0757
#>   `-- IF x1 >  0.695
#>      `-- Leaf Value: +0.8516