[英]random forest text classification giving extra rows in prediction
我正在使用随机森林进行文本分类。 我的输入数据有17197行。
> nrow(sparse_4testing)
[1] 17197
我在用
set.seed(123)
tweetRand = randomForest(label ~ ., data = train_sparse, importance=TRUE, nTree=500)
predicrRand_test=predict(tweetRand, data=sparse_4testing)
q1=data.frame(ifelse(predicrRand_test>0.5,1,0))
问题是当我进行完整性检查时,我在第1季度中得到了更多行
> nrow(q1)
[1] 22373
我不明白这个问题。 我是机器学习的新手。 请帮帮我。 我已经多次运行模型。 仍然遇到同样的问题。
> nrow(predicrRand_test)
NULL
> head(predicrRand_test)
1 3 6 7 9 10
1.858321e-01 -8.326673e-17 1.321640e-01 2.222222e-04 2.345304e-02 1.651133e-01
> head(q1)
ifelse.predicrRand_test...0.05..1..0.
1 1
3 0
6 1
7 0
9 0
10 1
> length(predicrRand_test)
[1] 22373
问题是由于predict
参数名称错误-它应该是newdata
,而不是data
( docs ):
predicrRand_test=predict(tweetRand, newdata=sparse_4testing)
到目前为止,您的代码将忽略data
参数,而仅返回predicrRand_test
数据predicrRand_test
的训练集的预测。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.