| ForwardMarginalEffect | R Documentation |
The FME is a forward difference in prediction due to a specified change in feature values.
featurevector of features
predictorPredictor object
step.sizevector of step sizes for features specified by "feature"
data.stepthe data.table with the data matrix after the step
ep.methodstring specifying extrapolation detection method
compute.nlmlogical specifying if NLM should be computed
nlm.intervalsnumber of intervals for computing NLMs
step.type"numerical" or "categorical"
extrapolation.idsvector of observation ids classified as extrapolation points
resultsdata.table with FMEs and NLMs computed
ameAverage Marginal Effect (AME) of observations in results
anlmAverage Non-linearity Measure (ANLM) of observations in results
computedlogical specifying if compute() has been run
new()Create a new ForwardMarginalEffect object.
ForwardMarginalEffect$new( predictor, features, ep.method = "none", compute.nlm = FALSE, nlm.intervals = 1 )
predictorPredictor object.
featuresA named list with the feature name(s) and step size(s).
ep.methodString specifying extrapolation detection method.
compute.nlmCompute NLM with FMEs? Defaults to FALSE.
nlm.intervalsHow many intervals for NLM computation. Defaults to 1.
A new ForwardMarginalEffect object.
# Train a model:
library(mlr3verse)
library(ranger)
data(bikes, package = "fmeffects")
forest = lrn("regr.ranger")$train(as_task_regr(x = bikes, target = "count"))
# Create an `ForwardMarginalEffect` object:
effects = ForwardMarginalEffect$new(makePredictor(forest, bikes),
features = list("temp" = 1, "humidity" = 0.01),
ep.method = "envelope")
compute()Computes results, i.e., FME (and NLMs) for non-extrapolation points, for a ForwardMarginalEffect object.
ForwardMarginalEffect$compute()
A ForwardMarginalEffect object with results.
# Compute results: effects$compute()
plot()Plots results, i.e., FME (and NLMs) for non-extrapolation points, for an FME object.
ForwardMarginalEffect$plot(with.nlm = FALSE, bins = 40, binwidth = NULL)
with.nlmPlots NLMs if computed, defaults to FALSE.
binsNumeric vector giving number of bins in both vertical and horizontal directions. Applies only to univariate or bivariate numeric effects.
See ggplot2::stat_summary_hex() for details.
binwidthNumeric vector giving bin width in both vertical and horizontal directions. Overrides bins if both set. Applies only to univariate or bivariate numeric effects.
See ggplot2::stat_summary_hex() for details.
# Compute results: effects$plot()
clone()The objects of this class are cloneable with this method.
ForwardMarginalEffect$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `ForwardMarginalEffect$new`
## ------------------------------------------------
# Train a model:
library(mlr3verse)
library(ranger)
data(bikes, package = "fmeffects")
forest = lrn("regr.ranger")$train(as_task_regr(x = bikes, target = "count"))
# Create an `ForwardMarginalEffect` object:
effects = ForwardMarginalEffect$new(makePredictor(forest, bikes),
features = list("temp" = 1, "humidity" = 0.01),
ep.method = "envelope")
## ------------------------------------------------
## Method `ForwardMarginalEffect$compute`
## ------------------------------------------------
# Compute results:
effects$compute()
## ------------------------------------------------
## Method `ForwardMarginalEffect$plot`
## ------------------------------------------------
# Compute results:
effects$plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.