Interpretable Machine Learning

Exercise

Author

Munir Eberhardt Hiabu

Published

April 1, 2024

Generate data from the following model.

n <- 5000
set.seed(42)
x1 <- sample(0:1, n, replace=TRUE)
x2 <- sample(18:65, n, replace=TRUE)
x3 <- sample(0:1, n, replace=TRUE)
x4 <- sample(0:1, n, replace=TRUE)

x <- cbind(x1,x2,x3,x4)

getlambda <- function(x1,x2,x3,x4){
0.2*(1+0.1*(x1==1))*(1+(1/(sqrt(x2-17))))*(1+(0.3*(18<=x2)*(x2<=35))*(x4==1)  -(0.3*(45<=x2)*(x2<=65))*(x4==1)  )
}
y <- sapply(1:n, function(i) rpois(1,getlambda(x1[i],x2[i],x3[i],x4[i])))
  1. Train a model of you choice on that data set.
  2. Provide a global explanation via partial dependence plots of your data. Discuss your result.