使用mahout进行k-means聚类[翻译]

http://mahout.apache.org/users/clustering/k-means-clustering.html


k-Means is a simple but well-known algorithm for grouping objects, clustering. All objects need to be represented as a set of numerical features. In addition, the user has to specify the number of groups (referred to as k) she wishes to identify.

k-Means可以对对象进行分组,这些对象需要被表示为特征值,并且制定要分为几组。

Each object can be thought of as being represented by some feature vector in an n dimensional space, n being the number of all features used to describe the objects to cluster. The algorithm then randomly chooses k points in that vector space, these point serve as the initial centers of the clusters. Afterwards all objects are each assigned to the center they are closest to. Usually the distance measure is chosen by the user and determined by the learning task.

聚类的思想:while (n 计算距离 }

After that, for each cluster a new center is computed by averaging the feature vectors of all objects assigned to it. The process of assigning objects and recomputing centers is repeated until the process converges. The algorithm can be proven to converge after a finite number of iterations.

Several tweaks concerning distance measure, initial center choice and computation of new average centers have been explored, as well as the estimation of the number of clusters k. Yet the main principle always remains the same.


Here is a short shell script outline that will get you started quickly with k-means. This does the following:

简短的运行k-means 的shell脚本大纲

  • Accepts clustering type: kmeans, fuzzykmeans, lda, or streamingkmeans
  • Gets the Reuters dataset
  • Runs org.apache.lucene.benchmark.utils.ExtractReuters to generate reuters-out from reuters-sgm (the downloaded archive)
  • Runs seqdirectory to convert reuters-out to SequenceFile format
  • Runs seq2sparse to convert SequenceFiles to sparse vector format
  • Runs k-means with 20 clusters
  • Runs clusterdump to show results
  • 接受聚类类型:
    1: kmeans, 2: fuzzykmeans, 3:lda, 4:streamingkmeans
  • 获取Reuters的数据集
  • 运行 org.apache.lucene.benchmark.utils.ExtractReuters 生成输出文件,直接运行脚本
  • 转换成二进制文件
  • 转换二进制文件为稀疏向量格式
  • 聚20个分类
  • 显示结果

路透社dataset下载地址:http://www.daviddlewis.com/resources/testcollections/reuters21578/

After following through the output that scrolls past, reading the code will offer you a better understanding.

利用word2vec对关键词进行聚类

你可能感兴趣的:(使用mahout进行k-means聚类[翻译])