Evaluation of similarity recommendation algorithm based on Euclidean distance Definition

Source: Internet
Author: User

Evaluation of similarity recommendation algorithm based on Euclidean distance Definition

/** This program evaluates the similarity defined based on Euclidean distance **/package byuser; 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. neighborhood. nearestNUserNeighborhood; import org. apache. mahout. cf. taste. impl. recommender. genericUserBasedRecommender; import org. apache. mahout. cf. taste. impl. similarity. euclideanDistanceSimilarity; 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 setting {public GenericRecByGroupLens_Evalu () throws Exception {DataModel model = new GroupLensDataModel (new File ("E :\\ mahout project \ examples \ ratings. dat "); RecommenderEvaluator evaluator = new evaluate (); RecommenderBuilder recommenderBuilder = new RecommenderBuilder () {@ Overridepublic Recommender buildRecommender (DataModel model) throws TasteException {// PearsonCoreCOnrrelationSimilarity is the Pearson correlation coefficient algorithm using UserSimilarity similarity = new PearsonCorrelationSimilarity (model ); // The algorithm UserSimilarity similarity1 = new EuclideanDistanceSimilarity (model); UserNeighborhood neighborhood = new feature (100, similarity1, model) is used here ); return new GenericUserBasedRecommender (model, neighborhood, similarity1) ;}; double score = evaluator. evaluate (recommenderBuilder, null, model, 0.95, 0.05); System. out. println ("the recommendation engine evaluation score based on the similarity defined by Euclidean distance is:" + score);} public static void main (String [] args) throws Exception {// TODO Auto-generated method stubGenericRecByGroupLens_Evalu eva = new GenericRecByGroupLens_Evalu ();}}

 

 

Here is the Pearson algorithm-based evaluation:

 

This is an evaluation based on the similarity defined by Euclidean distance:

 

We can see that the European algorithm is better than Pearson's recommendation algorithm.

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.