Evaluation of similarity recommendation algorithm based on Euclidean distance definition

Source: Internet
Author: User

/* * This program evaluates the similarity 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 GenericRecByGroupLens_ Evalu {PUblic Genericrecbygrouplens_evalu () throws Exception{datamodel model = new Grouplensdatamodel (New File ("E:\\mahout project \ \ Examples\\ratings.dat ")); Recommenderevaluator evaluator = new Averageabsolutedifferencerecommenderevaluator (); 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 used here is based on the Euclidean distance definition similarity usersimilarity similarity1 = new Euclideandistancesimilarity (model); Userneighborhood neighborhood = new Nearestnuserneighborhood (+, similarity1, model); return new Genericuserbasedrecommender (model, neighborhood, similarity1);}; Double score = evaluator.evaluate (Recommenderbuilder, NULL, model, 0.95, 0.05); SYSTEM.OUT.PRINTLN ("The evaluation score for the recommendation engine based on the Euclidean distance definition similarity is:" + score);} public static void Main (string[] args) throws Exception {//TODO auto-generated method Stubgenericrecbygrouplens_evalU eva = new Genericrecbygrouplens_evalu ();}} 




Here is an evaluation based on the Pearson algorithm:


This is based on the Euclidean distance definition similarity assessment:


It can be seen that the European algorithm is more superior to Pearson's recommendation algorithm

Evaluation of similarity recommendation algorithm based on Euclidean distance definition

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.