必须构建一个 Tf-idf 矩阵/数据框,其中术语/单词作为列名,而不是使用 sparklyr 的索引。我选择了 ft_count_vectorizer,因为它可以存储词汇。但是在找到 tf-idf 后我被卡住了,我无法将这些术语映射到它的 tf-idf 值。对此领域的任何帮助将不胜感激。这是我尝试过的。
tf_idf<-cleantext %>%
ft_tokenizer("Summary", "tokenized") %>%
ft_stop_words_remover(input.col = "tokenized", output.col = "clean_words",
ml_default_stop_words(sc,language = ("english"))) %>%
ft_count_vectorizer(input_col = "clean_words",output_col="tffeatures")%>%
ft_idf(input_col="tffeatures",output_col="tfidffeatures")
tf-idf 是一个 spark_tbl 类,它还包括 clean_words(vocabulary) 和 tfidf 特性。这两个特性都以列表的形式出现。我需要提供 tfidf 功能作为输入,并以 clean_words 作为列标题。最好的方法是什么。我被困在这里。任何帮助或帮助将不胜感激。