Description Usage Arguments Value Author(s) References Examples
View source: R/explainability.R
Computes explainability and matchplots for a partial dependence function.
1 2 3 4 5 6 7 8 9 10 |
model |
A model with corresponding predict function that returns numeric values. |
x |
Data frame. |
vnames |
Character vector of the variable set for which the patial dependence function is to be computed. |
viz |
Logical specifying whether a matchplot should be created. |
parallel |
Logical specifying whether computation should be parallel. |
sample.frac |
fraction-size for sampling of x. |
pfunction |
User generated predict function with arguments |
... |
Further arguments to be passed to the |
Numeric value with the explainability of the partial dependence function for the variables specified in vnames
.
Szepannek, G. (2019): How Much Can We See? A Note on Quantifying Explainability of Machine Learning Models, arXiv:1910.13376 [stat.ML].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(pdp)
library(randomForest)
data(boston)
set.seed(42)
boston.rf <- randomForest(cmedv ~ ., data = boston)
xpy(boston.rf, boston, c("lstat", "rm"))
# example 2: user-defined predict function for classification
library(klaR)
data("GermanCredit")
library(randomForest)
rfGC <- randomForest(credit_risk ~., data = GermanCredit)
# define predict function that returns continuous value (here: prob(yes))
pfunc = function(model, x) predict(model, x, type = "prob")[,2]
xpy(rfGC, GermanCredit, vnames = "duration", parallel = FALSE, pfunction = pfunc)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.