- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
tidytext 书有主题模型的 tidier 示例:
library(tidyverse)
library(tidytext)
library(topicmodels)
library(broom)
year_word_counts <- tibble(year = c("2007", "2008", "2009"),
+ word = c("dog", "cat", "chicken"),
+ n = c(1753L, 1157L, 1057L))
animal_dtm <- cast_dtm(data = year_word_counts, document = year, term = word, value = n)
animal_lda <- LDA(animal_dtm, k = 5, control = list( seed = 1234))
animal_lda <- tidy(animal_lda, matrix = "beta")
# Console output
Error in as.data.frame.default(x) :
cannot coerce class "structure("LDA_VEM", package = "topicmodels")" to a data.frame
In addition: Warning message:
In tidy.default(animal_lda, matrix = "beta") :
No method for tidying an S3 object of class LDA_VEM , using as.data.frame
复制同样出现的错误 here但在这种情况下 library(tidytext)
是 目前。
下面是所有包的列表及其对应的版本:
packageVersion("tidyverse")
‘1.2.1’
packageVersion("tidytext")
‘0.1.6’
packageVersion("topicmodels")
‘0.2.7’
packageVersion("broom")
‘0.4.3’
函数调用 sessionInfo()
的输出:
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] broom_0.4.3 tidytext_0.1.6 forcats_0.2.0 stringr_1.2.0 dplyr_0.7.4 purrr_0.2.4 readr_1.1.1 tidyr_0.8.0
[9] tibble_1.4.2 ggplot2_2.2.1 tidyverse_1.2.1 topicmodels_0.2-7
loaded via a namespace (and not attached):
[1] modeltools_0.2-21 slam_0.1-42 NLP_0.1-11 reshape2_1.4.3 haven_1.1.1 lattice_0.20-35 colorspace_1.3-2 SnowballC_0.5.1
[9] stats4_3.4.3 yaml_2.1.16 rlang_0.1.6 pillar_1.1.0 foreign_0.8-69 glue_1.2.0 modelr_0.1.1 readxl_1.0.0
[17] bindrcpp_0.2 bindr_0.1 plyr_1.8.4 munsell_0.4.3 gtable_0.2.0 cellranger_1.1.0 rvest_0.3.2 psych_1.7.8
[25] tm_0.7-3 parallel_3.4.3 tokenizers_0.1.4 Rcpp_0.12.15 scales_0.5.0 jsonlite_1.5 mnormt_1.5-5 hms_0.4.1
[33] stringi_1.1.6 grid_3.4.3 cli_1.0.0 tools_3.4.3 magrittr_1.5 lazyeval_0.2.1 janeaustenr_0.1.5 crayon_1.3.4
[41] pkgconfig_2.0.1 Matrix_1.2-12 xml2_1.2.0 lubridate_1.7.2 assertthat_0.2.0 httr_1.3.1 rstudioapi_0.7 R6_2.2.2
[49] nlme_3.1-131 compiler_3.4.3
最佳答案
删除 .Rhistory 和 .RData 导致正确的行为。
关于r - 使用 tidytext 和 broom 但没有找到 LDA_VEM 的 tidier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48765936/
使用 tidytext,我有这段代码: data(stop_words) tidy_documents % anti_join(stop_words) 我希望它使用包中内置的停用词将名为
我正在尝试将一个 pdf 文件文件夹读入 R 中的数据帧。我可以使用 pdftools 读取单个 pdf 文件。图书馆和 pdf_text(filepath) . 理想情况下,我可以获取一系列 pdf
我想使用 R 和 tidytext 对相似的单词进行聚类包裹。 我已经创建了我的 token ,现在想将其转换为矩阵以对其进行聚类。我想尝试一些 token 技术,看看哪种技术提供了最紧凑的集群。 我
让我从 Introduction to tidytext @ CRAN 中的以下完全工作的代码开始 library(janeaustenr) library(dplyr) library(string
更新:感谢您的投入。我重写了这个问题并添加了一个更好的例子来突出我的第一个例子中没有涵盖的隐含要求。 问题 我要找一个将军tidy删除包含停用词的 ngram 的解决方案。简而言之,ngram 是由空
我正在尝试将 unnest_tokens 与西类牙语文本一起使用。它可以很好地处理 unigrams,但会破坏 bigrams 的特殊字符。 代码在 Linux 上运行良好。我添加了一些关于语言环境的
我正在从 twitter 进行情感分析,但我的推文是西类牙语的,所以我不能使用 tidytext 对单词进行分类。有谁知道是否有类似的西类牙语套餐? 最佳答案 我在非英语文本挖掘中遇到了同样的问题。我
R 非常新,并且已经开始使用 tidytext 包。 我正在尝试使用参数输入 unnest_tokens功能,所以我可以做多列分析。所以而不是这个 library(janeaustenr) libra
这是一个奇怪的谜题。我从 gutenbergr 下载了 2 篇文章 - 爱丽丝梦游仙境和尤利西斯。停用词从 Alice 中消失,但它们仍在 Ulysses 中。即使将 anti_join 替换为过滤器
我目前正在使用 unnest_tokens()来自 tidytext 的函数包裹。它完全按照我的需要工作,但是,它从文本中删除了与号 (&)。我希望它不要那样做,但保持其他一切不变。 例如: libr
跟进 this question ,我想执行与 aggregate (或下面 MWE 中的 data.table 等效)相反的任务,以便我获得 df1再次从 df2 开始。 这里的任务是从 df2 重
我正在使用 tidytext包裹在 R做n-gram分析。 由于我分析推文,我想保留 @ 和 # 以捕获提及、转发和主题标签。然而,unnest_tokens功能自动删除所有标点符号并将文本转换为小写
tidytext 书有主题模型的 tidier 示例: library(tidyverse) library(tidytext) library(topicmodels) library(broom)
我正在尝试研究 tf-idf 加权语料库(我希望 tf 是按文档划分的比例,而不是简单的计数)。我希望所有经典文本挖掘库都会返回相同的值,但我得到了不同的值。我的代码中是否存在错误(例如,我是否需要转
我是一名优秀的程序员,十分优秀!