mit einem Klick
iml
// R iml package for interpretable ML. Use for model-agnostic interpretability methods.
// R iml package for interpretable ML. Use for model-agnostic interpretability methods.
R language data analysis and visualization skill. Use when user asks to (1) run R scripts or code, (2) install/update R packages, (3) perform data analysis with R, (4) create visualizations with ggplot2/plotly, (5) statistical analysis, (6) data manipulation with tidyverse/dplyr/data.table. Triggers on keywords like "R语言", "R脚本", "ggplot", "tidyverse", "数据分析", "可视化".
R DALEX package for model explanations. Use for explaining complex machine learning models.
R lime package for local explanations. Use for explaining individual predictions with local interpretable models.
R packages for ML interpretability. Use for explaining and interpreting machine learning models.
R vip package for variable importance. Use for computing and visualizing variable importance scores.
R machine learning packages. Use for classification, regression, clustering, deep learning, gradient boosting (xgboost, lightgbm), random forests, neural networks, and time series forecasting.
| name | iml |
| description | R iml package for interpretable ML. Use for model-agnostic interpretability methods. |
Interpretable Machine Learning.
library(iml)
# Create predictor object
predictor <- Predictor$new(
model = model,
data = train_data,
y = train_labels
)
# Permutation importance
imp <- FeatureImp$new(predictor, loss = "mse")
plot(imp)
# Results
imp$results
# Single feature
pdp <- FeatureEffect$new(predictor, feature = "age")
plot(pdp)
# Method options
pdp <- FeatureEffect$new(predictor, feature = "age",
method = "pdp") # Partial dependence
pdp <- FeatureEffect$new(predictor, feature = "age",
method = "ale") # Accumulated local effects
pdp <- FeatureEffect$new(predictor, feature = "age",
method = "pdp+ice") # PDP + ICE
# Two-way interaction
interact <- Interaction$new(predictor)
plot(interact)
# Specific feature
interact <- Interaction$new(predictor, feature = "age")
# Shapley values for single prediction
shap <- Shapley$new(predictor, x.interest = new_data[1, ])
plot(shap)
# Results
shap$results
# Local interpretable model
lime <- LocalModel$new(predictor, x.interest = new_data[1, ])
plot(lime)
# Results
lime$results
# Global surrogate
tree <- TreeSurrogate$new(predictor, maxdepth = 3)
plot(tree)
# Predict with surrogate
tree$predict(new_data)
# What-if counterfactuals
library(counterfactuals)
cf <- Counterfactuals$new(predictor, x.interest = new_data[1, ])
cf$find_counterfactuals(desired_outcome = 1)
# 2D PDP
pdp2d <- FeatureEffect$new(predictor,
feature = c("age", "income"),
method = "pdp")
plot(pdp2d)