0
我使用的神經網絡封裝庫情感分析做基礎實驗(neuralnet)神經網絡處理字符數據
the structure of my data is as follows:
'data.frame': 4442 obs. of 2 variables:
$ comment_text: chr "really briliant app\tit's intuitive and informative giving all the information you could need and seemingly very accurate." "will not connect to gps\tapp does not connect to gps no matter how long i have it on. i have gps set on high ac"| __truncated__ "wish this would interest more with google now to provide weekly or monthly summaries." "useless\tdoes not talk to gps on the phone. 20 minute run no data." ...
$ rating : int 5 1 5 1 4 5 4 3 4 5 ...
我是跳水這個數據到訓練和測試部分和運行神經網絡預測這樣的:
senti_train <- nnsenti[1:3499, ]
senti_test <- nnsenti[3500:4443, ]
library(neuralnet)
neuralmodel <- neuralnet(rating ~ comment_text, data=senti_train)
plot(neuralmodel)
後運行這個它給我這個錯誤
Error in neurons[[i]] %*% weights[[i]] :
requires numeric/complex matrix/vector arguments
如何解決這個文本是重要的組成部分
我已經符號化的文本數據,使用TM包做了一些文字清洗和更新了我的代碼如下:
nnsenti$comment_text <- VCorpus(VectorSource(nnsenti$comment_text))
#Text Cleaning
nnsenti$comment_text <- tm_map(nnsenti$comment_text,content_transformer(tolower))
nnsenti$comment_text <- tm_map(nnsenti$comment_text, removeNumbers)
nnsenti$comment_text <- tm_map(nnsenti$comment_text, removePunctuation)
nnsenti$comment_text <- tm_map(nnsenti$comment_text, removeWords,stopwords('english'))
nnsenti$comment_text <- tm_map(nnsenti$comment_text, removeWords,c('please','sad')) #Additional words
nnsenti$comment_text <- tm_map(nnsenti$comment_text, stripWhitespace)
senti_train <- nnsenti[1:3499, ]
senti_test <- nnsenti[3500:4443, ]
library(neuralnet)
neuralmodel <- neuralnet(rating ~ comment_text, data=senti_train)
現在我得到這個錯誤
Error in model.frame.default(formula.reverse, data) :
invalid type (list) for variable 'comment_text'
在運行任何ML模型之前,您需要標記文本數據。 – mtoto
我做了更改並更新了代碼,但仍然出現錯誤 – IronMaiden