我正在使用5 折分层交叉验证在我的数据集上使用frbs
包。R
我已经实施了分层简历。frbs.learn
我在每个折叠中使用 GFS.GCCL 方法进行函数,并使用测试数据预测结果。我收到此错误以及 30 条相同的警告消息:
错误:找不到对象“temp.rule.degree”
警告:在 max(MF.temp[m, ], na.rm = TRUE) 中:max 没有非缺失参数;返回-Inf
我的代码写在下面:
library(frbs)
data<-read.csv(file.address)
data[,30] <- unclass(data[,30]) #column 30 has the class of samples
data <- data[,c(1,14,20,26,27, 30)] # I choose to have 5 attr. since
#my data is high dimensional
k <- 5 # 5-fold
seed <- 1
folds <- strf.cv(data, k, seed) #stratification function for CV
range.data.inp <- matrix(apply(data[,-ncol(data)], 2, range), nrow=2)
data<-norm.data(as.matrix(data[,-ncol(data)]),range.data.
inp,min.scale = 0.1, max.scale = 1)
ctrl <- list(popu.size = 30, num.class = 2, num.labels= 3,
persen_cross = 0.9, max.gen = 200, persen_mutant = 0.3,
name="sim-1")
for(i in 1:k){
str <- paste("fold",i)
print(str)
test.ind <- folds[[str]]
test.data <- data[test.ind,]
train.data <- data[-test.ind,]
obj <- frbs.learn(train.data , method.type="GFS.GCCL",
range.data.inp , ctrl)
pred <- predict(obj, test.data)
print("Predicted classes:")
print(pred)
}
我对错误和警告一无所知。请让我知道我应该做什么。