このコードを使用して、quanteda NB から感情分析を予測しようとしています。
library(quanteda)
X_train <-c( "I love this sandwich.",
"This is an amazing place!",
"I feel very good about these beers.",
"This is my best work.",
"What an awesome view",
"I do not like this restaurant",
"I am tired of this stuff.",
"I can't deal with this",
"He is my sworn enemy!",
"this guy is horrible.")
Y_train <- c( 1,1,1,1,1,0,0,0,0,0)
Y_train <- c( 1,1,1,1,1,0,0,0,0,0)
X_test <- c( "The beer was good.",
"I do not enjoy my job",
"I ain't feeling dandy today.",
"I feel amazing! pos",
"Gary is a friend of mine.",
"I can't believ I'm doing this.",
"very sad about Iran",
"You're the only one who can see this cause no one else is following me this is for you because you're pretty awesome",
"ok thats it you win.",
"My horsie is moving on Saturday morning.",
"times by like a million",
"but i'm proud.",
"i want a hug)")
Y_test <- c(1,0,0,1,1,0,0,1,1,0,1,1,1)
dfm_mat <- dfm( X_train)
tfidf_mat <- tfidf( dfm_mat, normalize = TRUE)
model <- textmodel_NB( tfidf_mat, Y_train, distribution = "multinomial")
predict( model, X_test)
そして、次のエラーメッセージが表示されました:
Error in newdata %*% t(log(object$PwGc)) : not-yet-implemented method for <character> %*% <dgeMatrix>
5.stop(gettextf("not-yet-implemented method for <%s> %%*%% <%s>", class(x), class(y)), domain = NA)
4.newdata %*% t(log(object$PwGc))
3.newdata %*% t(log(object$PwGc))
2.predict.textmodel_NB_fitted(model, X_test)
1.predict(model, X_test)
実行中: quanteda_0.9.8.5
Matrix_1.2-7.1
R バージョン 3.3.1 (2016-06-21)
プラットフォーム: x86_64-pc-linux-gnu (64 ビット)
実行中: Ubuntu 16.10
誰でも何か思いつきましたか?