/* * 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