我有3个训练集文件和3个测试集文件。我想将 testset1 与 trainingset1 进行分类,将 testset2 与 trainingset2 进行分类,将 testset3 与 trainingset3 。
lapply
用于在多个文件上应用功能。但是,我想处理两组文件。
#Imbalanced Training Set
trainset <- list.files(path= "D:/Datasets/yeast-1-2-8-9_vs_7-5-fold/", pattern="tra.csv")
trainset
#trainset=read.csv("D:/Datasets/yeast-1-2-8-9_vs_7-5-fold/yeast-1-2-8-9_vs_7-5-2tra.csv")
#table(trainset$Class)
# Test Set Input
testset <- list.files(path= "D:/Datasets/yeast-1-2-8-9_vs_7-5-fold/", pattern="tst.csv")
testset
#testset=read.csv("D:/Datasets/yeast-1-2-8-9_vs_7-5-fold/yeast-1-2-8-9_vs_7-5-2tst.csv")
#table(testset$Class)
loopvariable=length(testset)
loopvariable
# Imbalance training set classifying test set results
for ( j in 1:loopvariable)
{
rftrainfirst<-randomForest(Class~., data=trainset[j])
rftrainfirst
rftrainfirst<-randomForest(Class~., data=trainset[j]). Here it is showing the following error.
terms.formula(formula,data = data)中的错误:“。”在公式和 没有“数据”参数