尝试在已保存的rda模型上使用预测函数时,我有一个NullPointerException
,请注意,当我直接使用该模型而不先保存它时,它会很好地工作,只有当我使用已保存的rda模型saveRDS()
函数,然后使用readRDS()
调用模型,我收到此错误。
完整错误:
Error in .jcall("RWekaInterfaces", "[D", "distributionForInstances", .jcast(classifier, :
java.lang.NullPointerException
代码如下:
training_1<-read.table("/data/CHURN_FILES/training_1.txt", sep="|", header=TRUE)
Model<- train(
x = subset(training_1, select = -c(Subs_Id,Churn_flag_OUT,Value_Segment,
Global_Profile
)), y = training_1$Churn_flag_OUT,
metric = "ROC" ,
method = "LMT",
trControl = myControl)
saveRDS(Hichem_Model, "/data/CHURN_FILES/Model.rda")
Model_2 <- readRDS("/data/CHURN_FILES/Model.rda")
My_Data$predict <- predict(Model_2 ,(subset(My_Data,
select = -c(Subs_Id,Churn_flag_OUT,Value_Segment,
Global_Profile))) , type = "prob")[,"churn"]