Dataset: The http://grouplens.org/datasets/movielens/ used kb before, now need to download movielens 10 m, use ratings. dat inside
Premise: because the file does not conform to the input format of the file in mahout, it needs to be converted. However, in example, grouplensdatamodel is a class for parsing the file, so it is used directly.
Package mahout; import Java. io. file; 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. impl. similarity. pearsoncorrelationsimilarity; import Org. apache. mahout. cf. taste. model. datamodel; import Org. apache. mahout. cf. taste. neighborhood. userneighborhood; 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 grouplensdatamodeltest {public static void main (string [] ARGs) throws exception {// use the custom grouplensdatamodel, if the dataset is not converted to a CSV format datamodel = new grouplensdatamodel (new file ("Data/ratings. data "); // Pearson correlation coefficient, measuring user similarity usersimilarity = new pearsoncorrelationsimilarity (datamodel); // building user neighbors, 100 userneighborhood = new neighbor (100, usersimilarity, datamodel); // recommender = new genericuserbasedrecommender (datamodel, userneighborhood, usersimilarity); // run loadevaluator. runload (recommender );}}
Run it, if your memory is large enough.
Output result:
My files have not been downloaded !!!!!!!!!!