Wikipedia Bayes Example

Intro

The Mahout Examples source comes with tools for classifying a Wikipedia data dump using either the Naive Bayes or Complementary Naive Bayes implementations in Mahout. The example (described below) gets a Wikipedia dump and then splits it up into chunks. These chunks are then further split by country. From these splits, a classifier is trained to predict what country an unseen article should be categorized into.

Running the example

  1. download the wikipedia data set here
  2. unzip the bz2 file to get the enwiki-latest-pages-articles.xml.
  3. Create directory $MAHOUT_HOME/examples/temp and copy the xml file into this directory
  4. Chunk the Data into pieces:
    $MAHOUT_HOME/bin/mahout wikipediaXMLSplitter -d $MAHOUT_HOME/examples/temp/enwiki-latest-pages-articles10.xml -o wikipedia/chunks -c 64

    We strongly suggest you backup the results to some other place so that you don't have to do this step again in case it gets accidentally erased

  5. This would have created the chunks in HDFS. Verify the same by executing
    hadoop fs -ls wikipedia/chunks

    and it'll list all the xml files as chunk-0001.xml and so on.

  6. Create the countries based Split of wikipedia dataset.
    $MAHOUT_HOME/bin/mahout  wikipediaDataSetCreator  -i wikipedia/chunks -o wikipediainput -c $MAHOUT_HOME/examples/src/test/resources/country.txt
    
  7. Verify the creation of input data set by executing
     hadoop fs -ls wikipediainput 

    and you'll be able to see part-r-00000 file inside wikipediainput directory

  8. Train the classifier:
    $MAHOUT_HOME/bin/mahout trainclassifier -i wikipediainput -o wikipediamodel

    . The model file will be available in the wikipediamodel folder in HDFS.

  9. Test the classifier:
    $MAHOUT_HOME/bin/mahout testclassifier -m wikipediamodel -d wikip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值