For canopy input data needs to be in the form of sequential files, while ensuring Key:text, http://www.aliyun.com/zixun/aggregation/9541.html "> Value:vectorwritable. Last night prepared to use a simple Java program to get ready to input data, but always will be a problem, last night's problem "can not find the file" for the moment has not found the reason.
In fact, if you just want to get input data, you can use the method provided by Mahout official website to copy the Mahout-distribution-0.7.zip to the virtual machine directly after getting the *.txt file of the sequence, (in/etc/ Profile to configure the next hadoop_home variable) and then locate the Mahout_home/bin directory, perform chmod +x mahout, and then perform the respective
[python] view plaincopy./mahout seqdirectory-i <input>-o <output> [python] view plaincopy./mahout Seq2sparse-i <output>/chunk-0-o <output-in>
The above <input>, <output> corresponds to its own input and output; The data I use is not the full data of the Reuters dataset, but the top three: REUT2-000.SGM, REUT2-001.SGM, REUT2-002.SGM, such data after Extractreuters became 3,000 files, and then after Seqdirectory merged into a 2.41M data file. Seq2sparse has 7 jobs, each job is responsible for its own content, this temporary analysis, the final result in the <output-in>/tfidf-vectors, that is, input data;
With the input data you can run the program, first, regardless of what the program looks like, first run out of the results to say:
[Java] view plaincopy package mahout.test.canopy; import java.io.ioexception; import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.path; Import org.apache.mahout.clustering.canopy.CanopyDriver; import org.apache.mahout.common.distance.distancemeasure; import org.apache.mahout.common.distance.euclideandistancemeasure; public class canopytest { Public static void main (String[] args) throws classnotfoundexception, ioexception, interruptedexception { Configuration conf =new configuration (); Conf.set (" Mapred.job.tracker ", " 192.168.128.138:9001 "); Path input=new path ( "Hdfs://hadoop:9000/user/hadoop/output/canopyvec/tfidf-vectors"); Path outPut=new path ("Hdfs://hadoop:9000/user/hadoop/output/canopy-output"); Distancemeasure measure=new euclideandistancemeasure (); Canopydriver.buildclusters (conf, input, output, measure, 33.1, 22.1, 3, False); SYSTEM.OUT.PRINTLN ("Job is done."); } }
At the beginning of my T1, T2 set to 3.1, 2.1 results map out of the result is 0 (this is not known what it means), and later changed to see the results of the map output of 509 records, Reduece Output 3 Records (the set value of the parameter Clusterfileter: 3), the final output is: canopy-output/clusters-0-final/part-r-00000.
In order to facilitate the observation of the following, so do not use the above data, and the use of their own data, to create data before the first need to know the format of the input data, then use the following code to see what the input data is:
[Java] view plaincopy package mahout.test.utils; Import java.io.IOException; Import org.apache.hadoop.conf.Configuration; Import Org.apache.hadoop.fs.Path; Import Org.apache.hadoop.io.Text; Import Org.apache.hadoop.mapreduce.Job; Import Org.apache.hadoop.mapreduce.Mapper; Import Org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat; Import Org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; Import Org.apache.hadoop.util.ToolRunner; Import Org.apache.mahout.common.AbstractJob;