calc_ALE_reg: Accumulated Local Effects for ERF

View source: R/calc_ALE_reg.R

calc_ALE_regR Documentation

Accumulated Local Effects for ERF

Description

Calculates the Accumulated Local Effects (ALE) from an ERF object

Usage

calc_ALE_reg(
  fit,
  var,
  save = TRUE,
  out.folder = NULL,
  cores = parallel::detectCores() - 4,
  type = "response",
  K = 50
)

Arguments

fit

The fitted object returned from calling ens_random_forests()

var

The name of the response variable

save

A logical flag to save the output as an RData object, default is TRUE.

out.folder

A path to the folder to write out too. If NULL then a folder is generated in the working directory

cores

An integer value that either indicates the number of cores to use for parallel processing or a negative value to indicate the number of cores to leave free. Default is to leave two cores free.

type

is either 'response' or 'prob' from predict.randomForest; if 'prob' then n sets of predictions are returned for the n levels in var; if "response" then the factorized predicted response values are returned

Value

A list that contains a data.frame for each variable, ordered by the mean variable importance, and a vector of the covariate values (used for rug plot in plot_ALE). The columns in each data.frame are as follows:

  • x: the covariate values that the ALE was calculated for

  • class: the class of the covariate; used by subsequent plot_ALE function

  • q: the quantile of the x value of the covariate

  • f.X: the ALEs evaluated at a given x value

Examples

#run an ERF with 10 RFs and 
ens_rf_ex <- ens_random_forests(df=simData$samples, var="obs", covariates=grep("cov", colnames(simData$samples),value=T), save=FALSE, cores=1)

ALEdf <- calc_ALE(ens_rf_ex, save=FALSE)
head(ALEdf[[1]]$df)


zsiders/EnsembleRandomForests documentation built on Oct. 8, 2024, 11:41 p.m.