【问题标题】:Document plotting using Pyplot and sklearn使用 Pyplot 和 sklearn 进行文档绘图
【发布时间】:2018-01-22 16:58:07
【问题描述】:

我希望深入了解我的文档集的布局。 我使用 SKlearn 的以下方法将它们转换为数字数组。

  pipeline = Pipeline([("vect", CountVectorizer()), 
                      ("tfidf", TfidfTransformer()),])

  matrix = pipeline.fit_transform(docs).todense()

如果我要对它们进行聚类,我会使用

    kmeans = KMeans(n_clusters=2).fit(matrix)
    data2D = kmeans.transform(matrix)

然后我会使用 pyplot 绘制它们

    plt.scatter(data2D[:,0], data2D[:,1], c = categories)

但是,这会生成数据集的 kmeans 表示。无论如何总结矩阵中的值并按原样绘制它们,这样我就可以在不使用kmeans的情况下查看它们之间的相对关系。这样我的表示是一致的eveytime。

【问题讨论】:

    标签: python matplotlib scikit-learn


    【解决方案1】:

    对于那些追随我的人。所讨论的原理被称为多维缩放。这是一个有用的博客,解释了它背后的原理。 https://de.dariah.eu/tatom/working_with_text.html

    【讨论】:

      猜你喜欢
      • 2016-07-21
      • 2018-11-22
      • 2015-11-20
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多