我尝试从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).