だから私は、Rのロジットモデルからの予測を理解するためにLIMEを使用しようとしています。「必要」ではないことはわかっていますが、出発点として簡単に理解できるモデルでLIMEが何をするかを説明しようとしていますプレゼンテーション。
しかし、これを機能させるのに問題があります。私はそれがmodel.predictの側面によるものだと確信していますが、私のいくつかの解決策はうまくいきませんでした.
基本的には、私がやりたいことは次のとおりです。
model.logit <- glm(formula = formula, data = build.dat, family = binomial(link = "logit"))
train.x <- build.dat[ , all.vars(formula[[3]])]
test.x <- reject.dat[1:100, all.vars(formula[[3]])]
explainer <- lime(train.x, as_classifier(model.logit ), n_bins = 20, quantile_bins = TRUE)
explain.me <- lime::explain(test.x[2 , ], explainer, n_labels = 1, n_features = 8, n_permutations = 5000,
feature_select = "forward_selection", type = "response" )
今、私はエラーが発生します
Error in match.arg(type) :'arg' should be one of “link”, “response”, “terms”
しかし、「ライム」コード内で「type = "response"」を移動しても修正されません。
そして、私がrandomForestを使用していて、それが機能したときに何が起こっていると思っていたのか、これを修正するかもしれないと思った関数「predict_model.glm」を作成しようとしました:
predict_model.glm <- function(x, newdata, type = "response" ) {
res <- as.data.frame(c(predict(x, newdata = newdata, type = type), 1-predict(x, newdata = newdata, type = type)))
}
しかし、これはエラーを追加するだけのようでした。
これは、「lime」の側面が探しているものを正確に見逃しているためだと確信しています (したがって、「predict_model.glm」関数でこれを修正できなかった) が、どこにも説明が見つからないようです。
どんな助けでも素晴らしいでしょう、ありがとう!