Mahout recommendation engine for Grouplens data customization

Source: Internet
Author: User

/* * This program is a Datamodel data model that is customized with Grouplens * Because the data here is separated by commas. * Here I have increased the amount of data into 20M data * The data model used here is for Grouplens custom Grouplensdatamodel * */package byuser;import Java.io.file;import Java.io.ioexception;import Java.util.list;import Org.apache.mahout.cf.taste.common.tasteexception;import Org.apache.mahout.cf.taste.impl.eval.loadevaluator;import Org.apache.mahout.cf.taste.impl.neighborhood.nearestnuserneighborhood;import Org.apache.mahout.cf.taste.impl.recommender.genericuserbasedrecommender;import Org.apache.mahout.cf.taste.model.datamodel;import Org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; Import Org.apache.mahout.cf.taste.recommender.recommendeditem;import Org.apache.mahout.cf.taste.recommender.recommender;import org.apache.mahout.cf.taste.similarity.UserSimilarity; Import Org.apache.mahout.cf.taste.similarity.precompute.example.grouplensdatamodel;public Class Genericuserrecommeder_grouplens {public static void main (string[] args) {//TODO auto-generated method Stubtry {//Loading of data Building a data ModelDatamodel model = new Grouplensdatamodel (New File ("E:\\mahout Project \\examples\\ratings.dat")); Usersimilarity similarity = new org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity (model); Userneighborhood neighborhood = new Nearestnuserneighborhood (similarity, model);//Generate recommendation engine Recommender Recommender = New Genericuserbasedrecommender (model, neighborhood, similarity); Loadevaluator.runload (recommender);//For the user has recommended a commodity recommend (,); where the parameter means: the first few people, and then recommend a few goods list<recommendeditem> Recommendations = Recommender.recommend (1, 1); for (Recommendeditem recommendation:recommendations) { System.out.println ("Grouplens custom, recommended product for you:" + Recommendation);}} catch (IOException e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (Tasteexception e) {//Todo Auto-gene Rated catch Blocke.printstacktrace ();}}}  The results of the data here will appear very slow, because the data here I run is 1M of data.






Mahout recommendation engine for Grouplens data customization

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.