Mahout快速入门教程

Mahout 是一个很强大的数据挖掘工具,是一个分布式机器学习算法的集合,包括:被称为Taste的分布式协同过滤的实现、分类、聚类等。Mahout最大的优点就是基于hadoop实现,把很多以前运行于单机上的算法,,转化为了MapReduce模式,这样大大提升了算法可处理的数据量和处理性能。一、Mahout安装、配置 1、下载并解压Mahouttar -zxvf mahout-distribution-0.9.tar.gz2、配置环境变量# set mahout environmentexport MAHOUT_HOME=/mnt/jediael/mahout/mahout-distribution-0.9export MAHOUT_CONF_DIR=$MAHOUT_HOME/confexport PATH=$MAHOUT_HOME/conf:$MAHOUT_HOME/bin:$PATH3、安装mahout[jediael@master mahout-distribution-0.9]$ pwd/mnt/jediael/mahout/mahout-distribution-0.9[jediael@master mahout-distribution-0.9]$ mvn install4、验证Mahout是否安装成功 执行命令mahout。若列出一些算法,则成功:[jediael@master mahout-distribution-0.9]$ mahoutRunning on hadoop, using /mnt/jediael/hadoop-1.2.1/bin/hadoop and HADOOP_CONF_DIR=MAHOUT-JOB: /mnt/jediael/mahout/mahout-distribution-0.9/examples/target/mahout-examples-0.9-job.jarAn example program must be given as the first argument.Valid program names are: arff.vector: : Generate Vectors from an ARFF file or directory baumwelch: : Baum-Welch algorithm for unsupervised HMM training canopy: : Canopy clustering cat: : Print a file or resource as the logistic regression models would see it cleansvd: : Cleanup and verification of SVD output clusterdump: : Dump cluster output to text clusterpp: : Groups Clustering Output In Clusters cmdump: : Dump confusion matrix in HTML or text formats concatmatrices: : Concatenates 2 matrices of same cardinality into a single matrix cvb: : LDA via Collapsed Variation Bayes (0th deriv. approx) cvb0_local: : LDA via Collapsed Variation Bayes, in memory locally. evaluateFactorization: : compute RMSE and MAE of a rating matrix factorization against probes fkmeans: : Fuzzy K-means clustering hmmpredict: : Generate random sequence of observations by given HMM itemsimilarity: : Compute the item-item-similarities for item-based collaborative filtering kmeans: : K-means clustering lucene.vector: : Generate Vectors from a Lucene index lucene2seq: : Generate Text SequenceFiles from a Lucene index matrixdump: : Dump matrix in CSV format matrixmult: : Take the product of two matrices parallelALS: : ALS-WR factorization of a rating matrix qualcluster: : Runs clustering experiments and summarizes results in a CSV recommendfactorized: : Compute recommendations using the factorization of a rating matrix recommenditembased: : Compute recommendations using item-based collaborative filtering regexconverter: : Convert text files on a per line basis based on regular expressions resplit: : Splits a set of SequenceFiles into a number of equal splits rowid: : Map SequenceFile<Text,VectorWritable> to {SequenceFile<IntWritable,VectorWritable>, SequenceFile<IntWritable,Text>} rowsimilarity: : Compute the pairwise similarities of the rows of a matrix runAdaptiveLogistic: : Score new production data using a probably trained and validated AdaptivelogisticRegression model runlogistic: : Run a logistic regression model against CSV data seq2encoded: : Encoded Sparse Vector generation from Text sequence files seq2sparse: : Sparse Vector generation from Text sequence files seqdirectory: : Generate sequence files (of Text) from a directory seqdumper: : Generic Sequence File dumper seqmailarchives: : Creates SequenceFile from a directory containing gzipped mail archives seqwiki: : Wikipedia xml dump to sequence file spectralkmeans: : Spectral k-means clustering split: : Split Input data into test and train sets splitDataset: : split a rating dataset into training and probe parts ssvd: : Stochastic SVD streamingkmeans: : Streaming k-means clustering svd: : Lanczos Singular Value Decomposition testnb: : Test the Vector-based Bayes classifier trainAdaptiveLogistic: : Train an AdaptivelogisticRegression model trainlogistic: : Train a logistic regression using stochastic gradient descent trainnb: : Train the Vector-based Bayes classifier transpose: : Take the transpose of a matrix validateAdaptiveLogistic: : Validate an AdaptivelogisticRegression model against hold-out data set vecdist: : Compute the distances between a set of Vectors (or Cluster or Canopy, they must fit in memory) and a list of Vectors vectordump: : Dump vectors from a sequence file to text viterbi: : Viterbi decoding of hidden states from given output states sequence二、使用简单示例验证mahout1、启动Hadoop2、下载测试数据 链接中的synthetic_control.data或者百度一下也很容易找到这个示例数据。3、上传测试数据hadoop fs -put synthetic_control.data testdata4、 使用Mahout中的kmeans聚类算法,执行命令:mahout -core org.apache.mahout.clustering.syntheticcontrol.kmeans.Job花费9分钟左右完成聚类 。 5、查看聚类结果 执行hadoop fs -ls /user/root/output,查看聚类结果。[jediael@master mahout-distribution-0.9]$ hadoop fs -ls outputFound 15 items-rw-r–r– 2 jediael supergroup194 2015-03-07 15:07 /user/jediael/output/_policydrwxr-xr-x – jediael supergroup0 2015-03-07 15:07 /user/jediael/output/clusteredPointsdrwxr-xr-x – jediael supergroup0 2015-03-07 15:02 /user/jediael/output/clusters-0drwxr-xr-x – jediael supergroup0 2015-03-07 15:02 /user/jediael/output/clusters-1drwxr-xr-x – jediael supergroup0 2015-03-07 15:07 /user/jediael/output/clusters-10-finaldrwxr-xr-x – jediael supergroup0 2015-03-07 15:03 /user/jediael/output/clusters-2drwxr-xr-x – jediael supergroup0 2015-03-07 15:03 /user/jediael/output/clusters-3drwxr-xr-x – jediael supergroup0 2015-03-07 15:04 /user/jediael/output/clusters-4drwxr-xr-x – jediael supergroup0 2015-03-07 15:04 /user/jediael/output/clusters-5drwxr-xr-x – jediael supergroup0 2015-03-07 15:05 /user/jediael/output/clusters-6drwxr-xr-x – jediael supergroup0 2015-03-07 15:05 /user/jediael/output/clusters-7drwxr-xr-x – jediael supergroup0 2015-03-07 15:06 /user/jediael/output/clusters-8drwxr-xr-x – jediael supergroup0 2015-03-07 15:07 /user/jediael/output/clusters-9drwxr-xr-x – jediael supergroup0 2015-03-07 15:02 /user/jediael/output/datadrwxr-xr-x – jediael supergroup0 2015-03-07 15:02 /user/jediael/output/random-seeds

我只愿,在你的理想和希望里能为你增加一点鼓励,

Mahout快速入门教程

相关文章:

你感兴趣的文章:

标签云: