- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 R 进行文本分类。我使用 DocumentTermMatrix 返回单词矩阵:
library(tm)
crude <- "japan korea usa uk albania azerbaijan"
corps <- Corpus(VectorSource(crude))
dtm <- DocumentTermMatrix(corps)
inspect(dtm)
words <- c("australia", "korea", "uganda", "japan", "argentina", "turkey")
test <- DocumentTermMatrix(corps, control=list(dictionary = words))
inspect(test)
第一个 inspect(dtm)
按预期工作,结果:
Terms
Docs albania azerbaijan japan korea usa
1 1 1 1 1 1
但是第二个 inspect(test)
显示这个结果:
Terms
Docs argentina australia japan korea turkey uganda
1 0 1 0 1 0 0
虽然预期的结果是:
Terms
Docs argentina australia japan korea turkey uganda
1 0 0 1 1 0 0
是bug还是我用错了?
最佳答案
Corpus() 在索引词频时似乎有一个错误。
改为使用 VCorpus(),这将为您提供预期的结果。
关于r - 在 R 中使用带有 'dictionary' 参数的 DocumentTermMatrix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44643961/
我和我的 friend 正在努力将我们收集的一些推文转换为 dtm,以便能够使用 R 中的机器学习运行情绪分析。任务必须在 R 中执行,因为它是为了我们的考试大学,要求将 R 用作工具。 最初我们收集
我正在尝试在相当大的数据集上使用 topicmodels 包中的 LDA()。在尝试了所有方法来修复以下错误“In nr * nc : NAs produced by integer overflow
我正在尝试在相当大的数据集上使用 topicmodels 包中的 LDA()。在尝试了所有方法来修复以下错误“In nr * nc : NAs produced by integer overflow
所以,我正在尝试使用 topicmodels包 R (大约 6400 个文档的语料库中的 100 个主题,每个文档大约 1000 个单词)。该进程运行然后死亡,我认为是因为它的内存不足。 所以我尝试缩
我有以下代码: # returns string w/o leading or trailing whitespace trim news_dtm traceback() 9: stop(spri
我对 R 很陌生,无法完全理解 DocumentTermMatrixs。我有一个用 TM 包创建的 DocumentTermMatrix,它有术语频率和里面的术语,但我不知道如何访问它们。 理想情况下
我正在尝试通过 text2vec 的 LDA 实现从 tm-package 运行 AssociatedPress 数据集。 我面临的问题是数据类型的不兼容:AssociatedPress 是一个 tm
我正在使用 R 中的 topicmodels 包进行主题建模。我正在创建一个 Corpus 对象,进行一些基本的预处理,然后创建一个 DocumentTermMatrix: corpus 0, ]
假设我有基于文本的训练数据和测试数据。更具体地说,我有两个数据集 - 训练和测试 - 并且它们都有一列,其中包含文本并且对当前的工作感兴趣。 我使用R中的tm包来处理训练数据集中的文本列。删除空格、标
我想使用 R 进行文本分类。我使用 DocumentTermMatrix 返回单词矩阵: library(tm) crude <- "japan korea usa uk albania azerba
我是新来的 tm包裹。我想用 DocumentTermMatrix函数来创建 DT-Matrix 以进行进一步的文本挖掘分析,但我能够为该函数创建适当的输入。 到目前为止,我的数据输入采用这样的字符向
我用过 tm包装和 DocumentTermMatrix创建一个 DocumentTermMatrix现在我想将其转换为备用矩阵以输出到 glmnet函数来自 glmnet包裹。 关于如何做到这一点的
我创建了一个 DocumentTermMatrix,其中包含 1859 个文档(行)和 25722 个(列)。为了对该矩阵执行进一步的计算,我需要将其转换为常规矩阵。我想用as.matrix()命令。
我有类似的问题,我从网上下载了一个很大的推文文件 将其保存为 data.txt 并使用 rstudio(导入数据集)加载到 R 中。 但有错误,无法继续。 This is step by step
我是一名优秀的程序员,十分优秀!