R/triplot.R
calculate_triplot.Rd
This function shows:
plot for the importance of single variables,
tree that shows importance for every newly expanded group of variables,
clustering tree.
calculate_triplot(x, ...) # S3 method for explainer calculate_triplot( x, type = c("predict", "model"), new_observation = NULL, N = 1000, loss_function = DALEX::loss_root_mean_square, B = 10, fi_type = c("raw", "ratio", "difference"), clust_method = "complete", cor_method = "spearman", ... ) # S3 method for default calculate_triplot( x, data, y = NULL, predict_function = predict, label = class(x)[1], type = c("predict", "model"), new_observation = NULL, N = 1000, loss_function = DALEX::loss_root_mean_square, B = 10, fi_type = c("raw", "ratio", "difference"), clust_method = "complete", cor_method = "spearman", ... ) # S3 method for triplot print(x, ...) model_triplot(x, ...) predict_triplot(x, ...)
x | an explainer created with the |
---|---|
... | other parameters |
type | if |
new_observation | selected observation with columns that corresponds to variables used in the model, should be without target variable |
N | number of rows to be sampled from data
NOTE: Small |
loss_function | a function that will be used to assess variable
importance, if |
B | integer, number of permutation rounds to perform on each variable
in feature importance calculation, if |
fi_type | character, type of transformation that should be applied for
dropout loss, if |
clust_method | the agglomeration method to be used, see
|
cor_method | the correlation method to be used see
|
data | dataset, it will be extracted from |
y | true labels for |
predict_function | predict function, it will be extracted from |
label | name of the model. By default it's extracted from the 'class' attribute of the model. |
triplot object
library(DALEX) set.seed(123) apartments_num <- apartments[,unlist(lapply(apartments, is.numeric))] apartments_num_lm_model <- lm(m2.price ~ ., data = apartments_num) apartments_num_new_observation <- apartments_num[30, ] explainer_apartments <- explain(model = apartments_num_lm_model, data = apartments_num[,-1], y = apartments_num[, 1], verbose = FALSE) apartments_tri <- calculate_triplot(x = explainer_apartments, new_observation = apartments_num_new_observation[-1]) apartments_tri