我正在尝试让RKEA在R Studio中工作。这是我当前的代码:
#Imports packages
library(RKEA)
library(tm)
#Creates a corpus of training sentences
data <- c("This is a sentence",
"I am in an office",
"I'm working on a laptop",
"I have a glass of water",
"There is a wooden desk",
"I have an apple for lunch")
data <- as.data.frame(data)
data <- Corpus(VectorSource(data$data))
#Creates a corpus of training keywords
keywords <- c("sentence",
"office",
"working",
"glass",
"wooden",
"apple")
keywords <- as.data.frame(keywords)
keywords <- Corpus(VectorSource(keywords$keywords))
#Creates output file for created model
tmpdir <- tempfile()
dir.create(tmpdir)
model <- file.path(tmpdir, "MyModel")
#Creates RKEA model
createModel(data, keywords, model)
这主要是根据RKEA文档中给出的示例进行建模的。但是,当我运行此命令时,出现以下错误消息:
Error in .jcall(km, "V", "saveModel") :
weka.core.WekaException: weka.classifiers.bayes.NaiveBayesSimple: Not enough training instances with class labels (required: 1, provided: 0)!
最佳答案
我认为您的例句作为文档太短了。以下修改(主要是对第一个示例文档)的修改没有错误:
data <- c("This is a longer and longer sentence.",
"I am in an office.",
"I'm working on a laptop.",
"I have a glass of water.",
"There is a wooden desk.",
"I have an apple for lunch.")
我的猜测是,在句子很短的情况下,没有足够多的词不是构建模型所用的关键词。
关于R RKEA-带有类标签的训练实例不足(必需的: 1,提供了: 0)!,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46792053/