`

Mahout: K-means clustering

 
阅读更多

K-means Algorithm

The k-means algorithm will start with an initial set of k centroid points. The algorithm does multiple rounds of processing and refines the centroid locations until the iteration max-limit criterion is reached or until the centroids converge to a fixed point from which they don’t move very much.


 

K-generation

  • centroids are randomly generated using RandomSeedGenerator

For good quality clustering using k-means, you’ll need to estimate a value for k. An approximate way of estimating k is to figure it out based on the data you have and the size of clusters you need. In the preceding example, where we have about a million news articles, if there are an average of 500 news articles published about every unique story, you should start your clustering with a k value of about 2,000 (1,000,000/500).

 

  • Finding the perfect k using canopy clustering

Canopy clustering’s strength lies in its ability to create clusters extremely quickly—it can do this with a single pass over the data. But its strength is also its weakness. This algorithm may not give accurate and precise clusters. But it can give the optimal number of clusters without even specifying the number of clusters, k, as required by k-means.

The algorithm uses a fast distance measure and two distance thresholds, T1 and T2, with T1 > T2. It begins with a data set of points and an empty list of canopies, and then iterates over the data set, creating canopies in the process. During each iteration, it removes a point from the data set and adds a canopy to the list with that point as the center. It loops through the rest of the points one by one. For each one, it calculates the distances to all the canopy centers in the list. If the distance between the point and any canopy center is within T1, it’s added into that canopy. If the distance is within T2, it’s removed from the list and thereby prevented from forming a new canopy in the subsequent loops. It repeats this process until the list is empty.
This approach prevents all points close to an already existing canopy (distance < T2) from being the center of a new canopy. It’s detrimental to form another redundant canopy in close proximity to an existing one.



 

 

mahout canopy 
-i reuters-vectors/tfidf-vectors \
-o reuters-canopy-centroids \
-dm org.apache.mahout.common.distance.EuclideanDistanceMeasure \
-t1 1500 -t2 2000

 

 

mahout kmeans 
-i mahout/reuters-vectors/tfidf-vectors 
-o mahout/reuters-kmeans-clusters 
-dm org.apache.mahout.common.distance.TanimotoDistanceMeasure 
-c mahout/reuters-canopy-centroids/clusters-0-final 
-cd 0.1 
-ow 
-x 20 
-cl

 

 

 

 mahout clusterdump 
-i mahout/reuters-kmeans-clusters/clusters-1-final 
-o mahout/reuters-kmeans-clusters-dump 
-dt sequencefile 
-d mahout/reuters-vectors/dictionary.file-* 
-p mahout/reuter-kmeans-clusters/clusteredPoints
-b 10 
-n 10

 mahout clusterdump usage



 

 Note: you must add -cl in kmean command otherwise there has no clusteredPoints dir. See

http://lucene.472066.n3.nabble.com/where-are-the-points-in-each-cluster-kmeans-clusterdump-tc838683.html#none

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 大小: 98.3 KB
  • 大小: 67.4 KB
  • 大小: 102.8 KB
分享到:
评论

相关推荐

    apache-mahout-distribution-0.11.0-src.zip

    - **聚类**:如K-Means算法,用于将数据点分成多个群组,使同组内的数据点相互接近,而不同组的数据点相距较远。 5. **大数据处理**: Mahout设计时考虑了大数据的处理,它利用Hadoop MapReduce框架进行分布式...

    mahout-core-0.9.jar+mahout-core-0.8.jar+mahout-core-0.1.jar

    聚类算法如K-means,用于将数据分成多个相似的组;分类算法如随机森林,用于预测目标变量。 2. **Hadoop支持**: Mahout是建立在Hadoop之上的,利用其分布式计算能力处理大规模数据集。这使得Mahout能够处理超出单...

    mahout-distribution-0.9.tar.gz

    3. **聚类**:包括K-Means、Fuzzy K-Means、Canopy Clustering、DBSCAN等算法,可用于将相似的数据点分组到一起,常用于市场细分、用户分群等场景。 4. **频繁项集挖掘**:通过Apriori、FP-Growth等算法发现数据...

    mahout所需jar包

    6. **查看结果**:K-Means算法完成后,结果将保存在HDFS(Hadoop分布式文件系统)或本地文件系统中,可以进一步分析或可视化。 **注意事项** - K-Means算法对初始中心点的选择敏感,可能会导致不同的聚类结果。...

    maven_mahout_template-mahout-0.8

    Mahout 0.8版本是一个重要的里程碑,包含了丰富的机器学习算法,如协同过滤推荐算法、K-means聚类算法、随机森林分类算法等。这些算法都是经过优化的,能够高效地运行在大规模数据集上,尤其适合处理大数据的场景。 ...

    mahout-distribution-0.5.tar.gz + 源码

    3. **聚类**:K-Means、Fuzzy K-Means和Canopy Clustering等方法用于将数据分组到相似的集合中,无监督学习的一种常见应用。 4. **特征选择与降维**:通过PCA(主成分分析)和其他方法减少数据的维度,以便更有效地...

    mahout-distribution-0.9含jar包

    3. **聚类**:包括K-means、Fuzzy K-means、Canopy Clustering等,用于将数据集分成多个具有相似特征的组。这些算法广泛应用于市场细分、用户分群和数据降维。 4. **矩阵分解**:如SVD(奇异值分解)和PMI(潜在...

    mahout-distribution-0.8-src

    2. **聚类(Clustering)**:包括K-means、Fuzzy K-means、Canopy Clustering等算法,用于将数据集中的对象分组到相似的类别中。这些算法广泛应用于市场细分、文本分类和图像分析等领域。 3. **分类...

    mahout-distribution-0.12.2-src.tar.gz

    1. **机器学习算法**:Mahout的核心在于它提供了多种机器学习算法,包括分类(如决策树、随机森林)、聚类(如K-Means、Fuzzy K-Means)、协同过滤(用于推荐系统)等。这些算法可以处理大规模数据,并且利用Hadoop...

    mahout-distribution-0.7-src.zip

    2. 聚类(Clustering):包括K-Means、Fuzzy K-Means、Canopy Clustering等算法,用于将数据点自动分组到相似的集合中。 3. 分类(Classification):支持基于概率的朴素贝叶斯分类器(NaiveBayesTrainer)和其他...

    Mahout-0.9-jar包

    2. **聚类**:包括K-Means、Fuzzy K-Means和Canopy Clustering等算法,可以对数据集进行无监督学习,将相似的数据点分组到一起,形成不同的簇。 3. **分类**:支持如Naive Bayes和Random Forest等监督学习算法,...

    apache-mahout-distribution-0.10.2

    2. **聚类(Clustering)**:如K-Means、Fuzzy K-Means和Canopy Clustering,用于将数据点自动分组到相似的集合中,无监督学习的一种常见应用。 3. **协同过滤(Collaborative Filtering)**:这是推荐系统的基础,...

    mahout数据挖掘

    - **Fuzzy K-Means**:K-Means 的扩展,允许一个样本属于多个聚类。 - **EM 聚类**:期望最大化算法,适用于数据存在缺失的情况。 - **Mean Shift 聚类**:无需事先指定聚类数量的算法。 - **Hierarchical ...

    mahout-distribution-0.5-src.tar.gz )

    此外,Mahout还支持其他聚类算法,如Fuzzy K-Means,适用于数据不精确或存在噪声的情况。 2. **分类算法**:Mahout的分类算法主要包括随机森林(Random Forest)和朴素贝叶斯(Naive Bayes)。随机森林是一种集成...

    聚类分析ppt

    #### 未知参数:K值的选择 在进行K-means聚类之前,需要预先确定聚类的数量K。通常可以通过尝试不同的K值并结合业务理解或者使用肘部法则(elbow method)等方法来确定最优的K值。 #### K-means算法流程 1. **初始化*...

    k-means-.rar_数值算法/人工智能_Java_

    - **对簇的大小和形状假设**:k-means假设簇是凸的且大小相近,对于非凸或者大小差异大的簇,效果可能不佳。 - **需要预先指定k值**:k值的选择对结果影响较大,但通常我们并不知道实际的簇数量。 - **处理离群点...

    mahout0.9 jar包支持hadoop2

    这个jar包提供了各种机器学习模型的构建和执行功能,如协同过滤、K-means聚类和随机森林等。通过Hadoop MapReduce,这些任务能够在分布式环境中高效运行。 "mahout-math-0.9.jar"是Mahout的数学库,提供了矩阵和...

    mahout canopy+kmeans测试数据

    Mahout的核心是它的聚类、分类、推荐系统和频繁项挖掘等算法,其中Canopy和K-means是其在聚类分析中的两个重要组成部分。 ### Mahout Canopy Canopy聚类算法是一种预聚类技术,常被用作K-means或其它更复杂的聚类...

Global site tag (gtag.js) - Google Analytics