# NOT RUN {
if (require("randomForest")) {
# First we fit a machine learning model on the Boston housing data
data("Boston", package = "MASS")
rf = randomForest(medv ~ ., data = Boston, ntree = 50)
X = Boston[-which(names(Boston) == "medv")]
mod = Predictor$new(rf, data = X)
# Then we explain the first instance of the dataset with the Shapley method:
x.interest = X[1,]
shapley = Shapley$new(mod, x.interest = x.interest)
plot(shapley)
}
# }
Run the code above in your browser using DataLab