我对集群文本的分析是全新的,我正在使用Goodreads来获取图书概要。我的目标是对类似的书籍进行分组,例如:
虽然Goodread提供了体裁,但我想使用概要并使用文本。让我说,我将得到N本书的概要如下:
<description>
<![CDATA[
<b>Alternate cover edition can be found <a href="https://www.goodreads.com/book/show/10249685-dune" rel="nofollow">here</a>. </b> and <a href="https://www.goodreads.com/book/show/11273438-dune" rel="nofollow">here</a><br /><br />Here is the novel that will be forever considered a triumph of the imagination. Set on the desert planet Arrakis, <b>Dune</b> is the story of the boy Paul Atreides, who would become the mysterious man known as Muad'Dib. He would avenge the traitorous plot against his noble family--and would bring to fruition humankind's most ancient and unattainable dream.<br />A stunning blend of adventure and mysticism, environmentalism and politics, Dune won the first Nebula Award, shared the Hugo Award, and formed the basis of what it undoubtedly the grandest epic in science fiction.
]]>
</description>我读过关于余弦相似性和新谷歌NLP的文章。但我想从以下几点开始:
问题:
任何其他的想法都会很棒。
发布于 2017-02-03 09:26:50
由于您要使用TF-国防军表示,您已经有了一个功能矩阵。要计算所有向量之间的余弦相似性,可以使用:
from sklearn.metrics.pairwise import cosine_similarity
similarity = cosine_similarity(tfidfmat)
#tfidfmat is your TF-IDF matrix#使用numpy数组
要开始聚类,可以首先使用K-均值算法,然后使用余弦相似性作为距离度量。下面是是一个来自scikit的例子--学习集群文档。
进一步的尝试:如果您发现上面的方法不符合您的期望,请查看word2vec和doc2vec,而不是使用tfidf,它是一包单词方法,使用单词向量表示。这里是一个很好的博客,解释了这个概念。
https://datascience.stackexchange.com/questions/16713
复制相似问题