我尝试从 R 中带有 iml 包的神经网络中获取变量的重要性。因变量是二进制的,并且预测变量是标准化的。我得到每个预测变量的缺失值。这是我正在使用的代码:
library(mlr)
library(iml)
tsk = makeClassifTask(data = fullnorm, target = "churn")
rfa <- makeLearner("classif.nnet", predict.type = "prob")# cross validation with NN
mod = train(rfa, tsk)
X =fullnorm[which(names(fullnorm) != "churn")]
Y <- as.numeric(as.character(fullnorm$churn))
predictor = iml::Predictor$new(mod, data = X, y = Y)
imp = FeatureImp$new(predictor, loss = "f1")
plot(imp)
除了缺失值(即所有预测变量)不合适的事实外,我没有收到任何消息。
> plot(imp)
Warning messages:
1: Removed 15 rows containing missing values (geom_point).
2: Removed 15 rows containing missing values (geom_segment).