第一步是读取数据:
library(RTextTools)
library(e1071)
pos_tweets = rbind(
c('I love this car', 'positive'),...,
c('I am so excited about the concert', 'positive'),
c('He is my best friend', 'positive')
)
neg_tweets...= rbind(pos_tweets,neg_tweets, test_tweets)
创建词条-文档矩阵:
# build dtm
matrix= create_matrix(
tweets[,1...(as.factor(tweets[11:15,2])), results[,"FORESTS_LABEL"])
recall_accuracy(as.numeric(as.factor(tweets[...(as.numeric(as.factor(tweets[11:15,2])), results[,"SVM_LABEL"])
得到模型的结果摘要(特别是结果的有效性):
# model summary