Mahout recommendation 4-evaluate the grouplens Dataset

Source: Internet
Author: User
Tags file info

Using the grouplens dataset UA. Base

This is a tab-separated file, user ID, item ID, rating (preference value), and additional information. Available? Previously, the CSV format is used, and now the TSV format is used. It is available and filedatamodel is used.

Use this dataset to test the Evaluation Program in mahout recommendation 2:

Package mahout; import Java. io. file; import Org. apache. mahout. cf. taste. common. tasteexception; import Org. apache. mahout. cf. taste. eval. recommenderbuilder; import Org. apache. mahout. cf. taste. eval. recommenderevaluator; import Org. apache. mahout. cf. taste. impl. eval. averageabsolutedifferencerecommenderevaluator; import Org. apache. mahout. cf. taste. impl. model. file. filedatamodel; 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. common. randomutils; public class testrecommenderevaluator {public static void main (string [] ARGs) throws exception {// force the same random value to be generated each time to generate repeated results randomutils. usetestseed (); // data loading // datamodel model = new filedatamodel (new file ("Data/intro.csv ")); datamodel model = new filedatamodel (new file ("Data/UA. base "); // recommendation evaluation, using average recommenderevaluator evaluator = new evaluate (); // recommendation evaluation, using average variance // recommenderevaluator evaluator = new rmsrecommenderevaluator (); // The Builder used to generate the recommendation engine. Same as the previous example, recommenderbuilder builder = new recommenderbuilder () {public recommender buildrecommender (datamodel Model) throws tasteexception {// todo auto-generated method stub // user similarity, multiple methods usersimilarity similarity = new neighbor (model); // user neighbor userneighborhood neighborhood = new neighbor (2, similarity, model); // a recommender return New genericuserbasedrecommender (model, neighborhood, similarity) ;}; // recommendation program evaluation value (average difference) Training 90% of the data, the test data is 10%. mahout in Action uses 0.7, but the result is nandouble score = evaluator. evaluate (builder, null, model, 0.9, 1.0); system. out. println (score );}}

Result output:

14/08/04 09:52:38 INFO file.FileDataModel: Creating FileDataModel for file data\ua.base14/08/04 09:52:38 INFO file.FileDataModel: Reading file info...14/08/04 09:52:38 INFO file.FileDataModel: Read lines: 9057014/08/04 09:52:38 INFO model.GenericDataModel: Processed 943 users14/08/04 09:52:38 INFO eval.AbstractDifferenceRecommenderEvaluator: Beginning evaluation using 0.9 of FileDataModel[dataFile:D:\workspace\zoodemo\data\ua.base]14/08/04 09:52:38 INFO model.GenericDataModel: Processed 943 users14/08/04 09:52:38 INFO eval.AbstractDifferenceRecommenderEvaluator: Beginning evaluation of 878 users14/08/04 09:52:38 INFO eval.AbstractDifferenceRecommenderEvaluator: Starting timing of 878 tasks in 4 threads14/08/04 09:52:39 INFO eval.StatsCallable: Average time per recommendation: 39ms14/08/04 09:52:39 INFO eval.StatsCallable: Approximate memory used: 16MB / 79MB14/08/04 09:52:39 INFO eval.StatsCallable: Unable to recommend in 114 cases14/08/04 09:52:43 INFO eval.AbstractDifferenceRecommenderEvaluator: Evaluation result: 0.93750000000000020.9375000000000002

It is based on 100 preference values, rather than a few

The result is about 0.9 in the range of 1 to 5. This value deviated from nearly one point, not too good.

Maybe the specific recommender implementation we are using is not optimal.

 

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.