Skip to main content
 首页 » 编程设计

python之使用 python scikit-learn 执行无监督文本分类(聚类)的最佳算法是什么

2024年10月01日7mfrbuaa

我尝试了 CountVectorizer + KMeans,但我不知道集群的数量。当我使用 gap statistic 时,计算 KMeans 中的簇数花费了很多时间方法。 NMF也需要事先确定组件的数量。

请您参考如下方法:

没有一种算法最适合无监督文本分类。这取决于您拥有的数据、您想要实现的目标等。

如果你想避免簇数问题,你可以尝试DBSCAN ,这是一种基于密度的聚类算法:

DBSCAN on Wikipedia: a density-based clustering algorithm: given a set of points in some space, it groups together points that are closely packed together (points with many nearby neighbors), marking as outliers points that lie alone in low-density regions (whose nearest neighbors are too far away).

DBSCAN 通过递归地将点连接到附近的密集点组(例如,一个簇)来自动找到簇的数量。

要使用 DBSCAN,最重要的调整参数是 epsilon(它控制被视为邻居的最大距离)和 min_samples(被视为核心点的邻居中的样本数)。尝试从 sklearn 提供的默认参数开始,并调整它们以获得更好的特定任务结果。