我最初有一个由 N 行中的 12 列组成的数据框。最后一列是我的班级(0 或 1)。我不得不将我的整个数据框转换为数字
training <- sapply(training.temp,as.numeric)
但是后来我认为我需要将类列作为因子列才能使用 randomforest() 工具作为分类器,所以我做了
training[,"Class"] <- factor(training[,ncol(training)])
我继续创建树
training_rf <- randomForest(Class ~., data = trainData, importance = TRUE, do.trace = 100)
但我遇到两个错误:
1: In Ops.factor(training[, "Status"], factor(training[, ncol(training)])) :
<= this is not relevant for factors (roughly translated)
2: In randomForest.default(m, y, ...) :
The response has five or fewer unique values. Are you sure you want to do regression?
如果有人能指出我所犯的格式错误,我将不胜感激。
谢谢!