zoukankan      html  css  js  c++  java
  • 学习Mahout(二)

    继续上一篇博客。

    这篇博客介绍如何跑一下mahout自带的Hello world程序

    我将mahout 安装在/opt/hadoop/mahout-distribution-0.9

    cd /opt/hadoop/mahout-distribution-0.9/examples/bin
    vi cluster-syntheticcontrol.sh

    搜索内容一个命令"curl",由于我的ubuntu 没有安装curl命令,所以需要修改一下

    原:

    curl http://archive.ics.uci.edu/ml/databases/synthetic_control/synthetic_control.data -o ${WORK_DIR}/synthetic_control.data

    修改成:

    #curl http://archive.ics.uci.edu/ml/databases/synthetic_control/synthetic_control.data -o ${WORK_DIR}/synthetic_control.data
    wget http://archive.ics.uci.edu/ml/databases/synthetic_control/synthetic_control.data
    mv synthetic_control.data ${WORK_DIR}

    这里其实就是到网上下载一个synthetic_control.data文件,我们使用wget工具就可以了。

    运行脚本:

    ./cluster-syntheticcontrol.sh

    显示一个选项,让你选择使用什么聚类算法来实现聚集。具体我也没有过多了解,这里我选择2
    Please select a number to choose the corresponding clustering algorithm
    1. canopy clustering
    2. kmeans clustering
    3. fuzzykmeans clustering
    Enter your choice : 2

    回车确认后,它就会执行:

    /opt/hadoop/mahout-distribution-0.9/bin/mahout org.apache.mahout.clustering.syntheticcontrol.kmeans.Job

    如果你展开/opt/hadoop/mahout-distribution-0.9/bin/mahout 这个脚本,发现实际它也是在加载了环境变量之后,调用

    ${HADOOP_HOME}/bin/hadoop jar mahout-examples-0.9-job.jar 
                   org.apache.mahout.driver.MahoutDriver  
                   org.apache.mahout.clustering.syntheticcontrol.kmeans.Job

    当然,在跑MapReduce 程序之前,它会先将data文件放在 HDFS 上。默认是放在/user/${user}/testdata 路径下。

    程序的结果放在 HDFS 的 /user/${user}/output/clusteredPoints/part-m-00000。这个文件不能直接打开查看,还需要转换一下格式。

    bin/mahout  seqdumper --input /user/root/output/clusteredPoints/ --output chenfool.txt

    它会将聚集的结果写到本地,这里是chenfool.txt文件

  • 相关阅读:
    51nod 1087 1 10 100 1000(找规律+递推+stl)
    51nod 1082 与7无关的数 (打表预处理)
    51 nod 1080 两个数的平方和
    1015 水仙花数(水题)
    51 nod 1003 阶乘后面0的数量
    51nod 1002 数塔取数问题
    51 nod 1001 数组中和等于K的数对
    51 nod 1081 子段求和
    51nod 1134 最长递增子序列 (O(nlogn)算法)
    51nod 1174 区间中最大的数(RMQ)
  • 原文地址:https://www.cnblogs.com/chenfool/p/3806027.html
Copyright © 2011-2022 走看看