-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rhistory
47 lines (47 loc) · 1.27 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
install.packages("distill")
library(distill)
create_theme(name = "treebook")
?treemisc::banknote
?alr3::banknote
install.packages("alr3")
?alr3::banknote
install.packages("alr4")
install.packages("quarto")
?treemisc::banknote
file.choose()
write.csv(treemisc::banknote, file='datasets/banknote.csv', row.names = FALSE)
library(pdp)
summary(lm(cmedv ~ ., data = boston))
knitr::opts_chunk$set(echo = TRUE)
head(aq <- airquality)
aq
write.csv(aq, file='datasets/airquality.csv', row.names = F)
set.seed(943) # for reproducibility
treemisc::gen_friedman1(5, nx = 7, sigma = 0.1)
treemisc::gen_friedman1
library(fastshap)
x1 <- c(1,1,1,0,0,0,0,0,0,0)
x2 <- c(1,0,0,1,1,1,0,0,0,0)
x3 <- c(3,2,1,3,2,1,3,2,1,3)
x4 <- c(1,0,1,1,0,1,0,1,0,1)
y <- c(1,0,1,0,1,1,0,0,0,1)
df <- data.frame(x1, x2, x3, x4, y)
fit <- glm(y ~ ., data=df, family=binomial)
X <- model.matrix(y ~., df)[,-1]
fit
pfun <- function(object, newdata) {
predict(object, type="response")
}
pfun(fit, df)
shap <- explain(fit , X = X, pred_wrapper = pfun, nsim = 100)
shap
predict(object, type="link")
pfun <- function(object, newdata) {
predict(object, type="link")
}
shap <- explain(fit , X = X, pred_wrapper = pfun, nsim = 100)
shap
shap <- explain(fit , X = X, pred_wrapper = pfun, nsim = 100, exact=F)
shap
pfun(fit, df)
summary(fit)