mahout (一)kmeans的使用


kMeans命令行介绍

本文快速介绍如何在Hadoop集群上运行k Means集群算法。

步骤

Mahout的k-Means集群可以从相同的命令行调用中启动,无论您是在独立模式下还是在更大的Hadoop集群上运行。区别取决于$ HADOOP_HOME和$ HADOOP_CONF_DIR环境变量。 如果两者都设置为目标机器上正在运行的Hadoop集群,则该调用将在该集群上运行k-Means。如果两个环境变量的缺失则单机Hadoop配置将改为调用。

在$ MAHOUT_HOME /中,构建包含作业的jar(mvn install)作业将在$ MAHOUT_HOME / core / target /中生成,其名称将包含Mahout版本号。例如,当使用Mahout 0.3版本时,作业将是mahout-core-0.3.job

在一台没有集群的机器上进行测试
     把数据:cp testdata
     运行工作:
     ./bin/mahout kmeans -i testdata -o output -c clusters -dm org.apache.mahout.common.distance.CosineDistanceMeasure -x 5 -ow -cd 1 -k 25

在集群上运行它
  (根据需要)启动Hadoop:$ HADOOP_HOME / bin / start-all.sh
     把数据:$ HADOOP_HOME / bin / hadoop fs -put testdata
     运行工作:
     export HADOOP_HOME = export HADOOP_CONF_DIR = $ HADOOP_HOME / conf ./bin/mahout kmeans -i testdata -o output -c clusters -dm org.apache.mahout.common.distance.CosineDistanceMeasure -x 5 -ow -cd 1 -k 25
     从HDFS获取数据,看看。 使用bin / hadoop fs -lsr输出查看所有输出。

Command line options

  --input (-i) input			       Path to job input directory. 
					       Must be a SequenceFile of    
					       VectorWritable		    
  --clusters (-c) clusters		       The input centroids, as Vectors. 
					       Must be a SequenceFile of    
					       Writable, Cluster/Canopy. If k  
					       is also specified, then a random 
					       set of vectors will be selected  
					       and written out to this path 
					       first			    
  --output (-o) output			       The directory pathname for   
					       output.			    
  --distanceMeasure (-dm) distanceMeasure      The classname of the	    
					       DistanceMeasure. Default is  
					       SquaredEuclidean 	    
  --convergenceDelta (-cd) convergenceDelta    The convergence delta value. 
					       Default is 0.5		    
  --maxIter (-x) maxIter		       The maximum number of	    
					       iterations.		    
  --maxRed (-r) maxRed			       The number of reduce tasks.  
					       Defaults to 2		    
  --k (-k) k				       The k in k-Means.  If specified, 
					       then a random selection of k 
					       Vectors will be chosen as the    
					       Centroid and written to the  
					       clusters input path.	    
  --overwrite (-ow)			       If present, overwrite the output 
					       directory before running job 
  --help (-h)				       Print out help		    
  --clustering (-cl)			       If present, run clustering after 
					       the iterations have taken place  



原文地址:http://mahout.apache.org/users/clustering/k-means-commandline.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值