我尝试使用R创建一个RandomForst模型进行情绪分析: 代码如下:
data = as.data.frame(as.matrix(dtm_train), stringsAsFactors = T)
>data
accueil bon depuis banque client très service conseiller agence a plus je
634 0 0 0 0 0 0 0 0 0 0 0 0
3802 0 0 0 0 0 0 0 0 0 0 0 0
16739 0 0 0 0 0 1 0 0 0 0 0 1
20992 0 0 0 0 0 0 0 0 0 0 0 0
4742 0 0 0 0 0 0 0 0 0 0 0 0
5104 0 0 1 0 0 0 0 0 0 0 0 0
6978 1 1 0 1 0 0 0 0 0 0 0 0
21630 0 2 0 0 0 0 1 0 0 0 0 0
13606 0 0 0 0 0 0 0 0 0 0 0 0
21910 0 0 0 0 0 0 0 1 0 0 0 0
8184 0 0 0 0 0 0 0 0 0 0 0 0
...
Note = train[['Note.Reco']]
> Note
[1] 9 10 9 0 10 8 10 7 10 10 5 5 8 8 2 9 8 0 10 10 8 0 8 7 7 6 9 10 8 9 5 10 10 0 5 3 2 8 8 1 7 6 0 8 9 0 5 5 8 6 8
[52] 8 7 8 9 9 9 10 5 4 5 8 8 8 9 9 10 9 8 4 10 9 8 8 8 8 5 0 9 8 7 5 3 2 10 8 10 9 0 10 6 10 8 5 9 10 1 8 9 1
reviews.test = test$reason
[1] "Pas assez service......"
[2] "Pour résidant s....."
[3] " emails, réponses ...."
[4] "Même ...."
review.test_DF = as.data.frame(reviews.test,stringsAsFactors = T)
reviews.svm = randomForest(Note~., data)
pred.svm = predict(reviews.svm, review.test_DF, type="class")
我收到此错误:
> pred.svm = predict(reviews.svm, review.test_DF, type="class")
Error in eval(expr, envir, enclos) : object 'accueil' not found
你能帮我解决这个问题吗?
提前谢谢