| Surrogate | R Documentation |
The class for distilled surrogate models.
interpreterThe interpreter object to use as a standardized wrapper for the model
featuresThe indices of the features in the data used in the surrogate model
weightsThe weights used to recombine the PDPs into a surrogate for the original model
interceptThe intercept term we use for our predictions
feature.centersThe center value for the features determined in the model
center.meanBoolean value that determines whether we use the mean-centered data for our predictions
gridA list of PDPS that determine our prediction.
snap.gridBoolean that determines whether we use grid.points
new()Surrogate$new( interpreter, features, weights, intercept, feature.centers, center.mean, grid, snap.grid )
interpreterThe interpreter object we want to build a surrogate model for.
featuresThe indices of features in the training data used for the surrogate model
weightsThe weights for each given feature after the surrogate model is fit.
interceptThe baseline value. If uncentered, this is 0, and if centered, this will be the mean of the predictions of the original model on the training data.
feature.centersThe baseline value for the effect of each feature. If uncentered, this is 0.
center.meanA boolean value that shows whether this model is a centered or uncentered model
gridA list of dataframes containing the pre-calculated values used to generate predictions if snap.grid is TRUE
snap.gridBoolean that determines if we use previously calculated values or re-predict using the functions.
A surrogate model object that we can use for predictions
clone()The objects of this class are cloneable with this method.
Surrogate$clone(deep = FALSE)
deepWhether to make a deep clone.
Do not initalize this class on its own. It is automatically created by the distill function for the interpreter class.
library(distillML)
library(Rforestry)
set.seed(491)
data <- iris
test_ind <- sample(1:nrow(data), nrow(data)%/%5)
train_reg <- data[-test_ind,]
test_reg <- data[test_ind,]
forest <- forestry(x=data[,-1],
y=data[,1])
forest_predictor <- Predictor$new(model = forest, data=train_reg,
y="Sepal.Length", task = "regression")
forest_interpret <- Interpreter$new(predictor = forest_predictor)
# Both initializations of a surrogate class result in the same surrogate model
surrogate.model <- distill(forest_interpret)
surrogate.model <- distill(forest_interpret,
center.mean = TRUE,
features = 1:length(forest_interpret$features),
cv = FALSE,
snap.grid = TRUE,
snap.train = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.