plotProximity {bartMan}R Documentation

plotProximity

Description

Plot a proximity matrix

Usage

plotProximity(
  matrix,
  pal = rev(colorspace::sequential_hcl(palette = "Blues 2", n = 100)),
  limit = NULL
)

Arguments

matrix

A matrix of proximities created by the proximityMatrix function

pal

A vector of colours to show proximity scores, for use with scale_fill_gradientn.

limit

Specifies the fit range for the color map for proximity scores.

Value

A plot of proximity values.

Examples

if(requireNamespace("dbarts", quietly = TRUE)){
 # Load the dbarts package to access the bart function
 library(dbarts)
 # Get Data
 df <- na.omit(airquality)
 # Create Simple dbarts Model For Regression:
 set.seed(1701)
 dbartModel <- bart(df[2:6],
   df[, 1],
   ntree = 5,
   keeptrees = TRUE,
   nskip = 10,
   ndpost = 10)
 # Tree Data
 trees_data <- extractTreeData(model = dbartModel, data = df)
 # Create Proximity Matrix
 mProx <- proximityMatrix(trees = trees_data, reorder = TRUE, normalize = TRUE, iter = 1)
 # Plot
 plotProximity(matrix = mProx)
}

[Package bartMan version 0.1.1 Index]