-
-
Save apoorvalal/388bdad03120c6197659ee9909cd7a74 to your computer and use it in GitHub Desktop.
basic example of pdp / ice / ale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("iml") | |
library("randomForest") | |
data("Boston", package = "MASS") | |
# %% | |
rf = randomForest(medv ~ ., data = Boston, ntree = 50) | |
X = Boston[which(names(Boston) != "medv")] | |
# %% | |
model = Predictor$new(rf, data = X, y = Boston$medv) | |
# %% ALE | |
effect = FeatureEffects$new(model) | |
effect$plot() | |
# %% PDP | |
pdp <- FeatureEffects$new(model, method = 'pdp') | |
pdp$plot() | |
# %% | |
pdpi <- FeatureEffects$new(model, method = 'pdp+ice') | |
pdpi$plot() | |
# %% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment