Eclipse Configuration Mahout

Source: Internet
Author: User

1. Build a Java Project project name on Elcipse: mymahout

2. Create the Libs folder and find the Java package under the Mahout 0.9 lib folder

Where log4j.properties can be found under the Hadoop folder.

Put them under the Libs folder.

3. Copy the folder Libs to the Mymahout project

4. Click the Libs folder, right, select Build Path, and bring the file under the Libs folder.

5. Create the class Mahout and write the following code

ImportJava.io.File;Importjava.util.List;ImportOrg.apache.mahout.cf.taste.impl.model.file.*;ImportOrg.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;ImportOrg.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;Importorg.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;ImportOrg.apache.mahout.cf.taste.model.DataModel;ImportOrg.apache.mahout.cf.taste.neighborhood.UserNeighborhood;ImportOrg.apache.mahout.cf.taste.recommender.RecommendedItem;ImportOrg.apache.mahout.cf.taste.recommender.Recommender;Importorg.apache.mahout.cf.taste.similarity.UserSimilarity; Public classMahout { Public Static voidMain (string[] args)throwsException {Datamodel model=NewFiledatamodel (NewFile ("/users/jia/desktop/test.txt")); Usersimilarity Similarity=Newpearsoncorrelationsimilarity (model); Userneighborhood Neighborhood=NewNearestnuserneighborhood (2, Similarity,model); Recommender Recommender=NewGenericuserbasedrecommender (model,neighborhood,similarity); List<RecommendedItem> Recommendations =recommender.recommend (1, 2);  for(Recommendeditem recommendation:recommendations) {SYSTEM.OUT.PRINTLN (recommendation); }    }}
View Code

6. Running Results

The red section suggests that if you run with a Hadoop cluster, the journal file will be written. This is not to run on the cluster, so alert.

Eclipse Configuration Mahout

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.