问题描述
我正在尝试在文本数据上训练朴素贝叶斯模型,该模型具有预定的折叠数(以便与其他模型进行比较),并采用自适应重采样进行超参数调整。但是,出现此错误:
if(tmps <.machine double.eps else tmpm tmps false>
我知道还有其他方法,例如Quanteda软件包提供的方法,但是,我想继续使用脱字号,以便能够使用相同的数据比较其他模型。
任何帮助将不胜感激。
我的代码如下:
library(tidyverse)
library(quanteda)
library(quanteda.textmodels)
library(caret)
corp <- data_corpus_moviereviews
set.seed(300)
id_train <- sample(docnames(corp),size = 1500,replace = FALSE)
# get training set
training_dfm <- corpus_subset(corp,docnames(corp) %in% id_train) %>%
dfm(stem = TRUE,tolower=TRUE,remove=stopwords("en"),remove_symbols=TRUE)
# get test set (documents not in id_train,make features equal)
test_dfm <- corpus_subset(corp,!docnames(corp) %in% id_train) %>%
dfm(stem = TRUE,remove_symbols=TRUE,remove=stopwords("en")) %>%
dfm_select(pattern = training_dfm,selection = "keep")
training_m <- convert(training_dfm,to = "matrix")
test_m <- convert(test_dfm,to = "matrix")
myFolds <- createFolds(training_m,k = 5)
myControl <- trainControl(
method="adaptive_cv",repeats=2,summaryFunction = twoClassSummary,classprobs = TRUE,verboseIter = TRUE,index = myFolds,adaptive = list(min = 2,alpha = 0.05,method = "gls",complete = TRUE),search = "random")
nb_caret <- train(x = training_m,y = as.factor(docvars(training_dfm,"sentiment")),method = "naive_bayes",trControl = myControl,tuneLength = 3,verbose = TRUE,metric = "ROC") ```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)