1

現在、tm パッケージを使用して、デスクトップ上で実行される 25,000 アイテム (30Mb) の適切なサイズのデータ​​ベースで重複検出のためにクラスター化する用語を抽出していますが、サーバー上で実行しようとすると、途方もない時間。詳しく調べてみると、用語の頻度を計算するために apply(posts.TmDoc, 1, sum) 行を実行して 4 GB のスワップを使い果たしたことがわかりました。さらに、as.matrix を実行してもデスクトップに 3GB のドキュメントが生成されますhttp://imgur.com/a/wllXvを参照してください

これは、25,000 個のアイテムで 18,000 個の用語の頻度カウントを生成するためだけに必要ですか? TermDocumentMatrix を行列またはベクトルに強制せずに頻度カウントを生成する他の方法はありますか?

スパース性に基づいて用語を削除することはできません。これが実際のアルゴリズムの実装方法です。2 つ以上 50 以下の用語とそれらのグループに共通する用語を探し、各グループの類似値を計算します。

参照用のコンテキスト内のコードは次のとおりです

min_word_length = 5
max_word_length = Inf
max_term_occurance = 50
min_term_occurance = 2


# Get All The Posts
Posts = db.getAllPosts()
posts.corpus = Corpus(VectorSource(Posts[,"provider_title"]))

# remove things we don't want
posts.corpus = tm_map(posts.corpus,content_transformer(tolower))
posts.corpus = tm_map(posts.corpus, removePunctuation)
posts.corpus = tm_map(posts.corpus, removeNumbers)
posts.corpus = tm_map(posts.corpus, removeWords, stopwords('english'))

# grab any words longer than 5 characters
posts.TmDoc = TermDocumentMatrix(posts.corpus, control=list(wordLengths=c(min_word_length, max_word_length)))

# get the words that occur more than once, but not more than 50 times
clustterms = names(which(apply(posts.TmDoc, 1, sum) >= min_term_occurance  & apply(posts.TmDoc, 1, sum) < max_term_occurance))
4

1 に答える 1