[英]How can I run LIME on text data using random forest in R
我正在尝试使用 R 对带有随机森林 model 的文本数据运行 LIME。 However, while running the 'lime::explain' function, I am continuously getting an error "Error in as.data.frame.default(newdata, stringsAsFactors = TRUE): cannot coerce class 'structure("dgCMatrix", package = "矩阵“)”到一个data.frame“。 我已经尽我所能解决它,但我无法自己解决。 有人能帮助我吗?
作为参考,我使用一个例子“https://www.shirin-glander.de/2018/07/explaining_ml_models_code_text_lime/”
rf <- train(x = as.matrix(dtm_train2),
y = factor(clothing_reviews_train$Liked),
method = "ranger",
num.trees = 10,
importance = "impurity"
)
explainer <- lime(clothing_reviews_train$text,
congress_rf,
preprocess = create_dtm_mat)
解释 <- 石灰::解释(clothing_reviews_test$text[1:4],解释器,n_labels = 1,n_features = 5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.