The mahout of recommendation engine based on user collaborative filtering algorithm

Source: Internet
Author: User

Objective: To introduce the use of a common recommendation algorithm (user collaborative filtering).

Application scenario: After the XXX project runs for a period of time, there will be a lot of video information in the system, and usually the app gives the user push messages (1-3/day),

Then this requires us to push more effectively based on the user's behavioral characteristics.

Tool Introduction: The use of mahout collaborative filtering algorithm

Test code:

/** *  *  based on user's neighbor collaborative filtering recommendation algorithm, *  This paper aims to provide some reference algorithms for the recommended algorithm of XXX follow-up advertisement  *  *  @ All rights reserved: Come to Yi Finance   copyright   (c)  2015 *  @author  feihu.wang *  @version   revision 1.0.0 *  @see:  * @ Date Created: May 18, 2015  * @ feature description:  * */public  class cftest {    public static void main (String[]  args)  throws IOException, TasteException {                   DataModel model = new  Filedatamodel (New file ("E:\\projects\\code\\mahout_test\\intro.csv"));                   //user acquaintance degree  : Pearson relevance myopia          //UserSimilarity sim = new  Pearsoncorrelationsimilarity (model);                  //user acquaintance degree  : European distance          usersimilarity sim = new euclideandistancesimilarity (model);                 //  Nearest Neighbor algorithm         UserNeighborhood nbh = new  Nearestnuserneighborhood (2, sim, model);                     //  generate recommendation engine   :  user-based collaborative filtering algorithm,          //also has an item-based filtering algorithm,mahout  There are many implementations below          recommender rec = new genericuserbasedrecommender (model,  nbh, sim);                     // Recommended items for user ID (1) (Qty 2)           List<RecommendedItem>  recitemlist = rec.recommend (1, 2);                     for (recommendeditem item :  Recitemlist)  {               SYSTEM.OUT.PRINTLN (item);          }                 }

Test data:

Intro.csv

Pom dependency:

<dependency><groupid>org.apache.mahout</groupid><artifactid>mahout-core</artifactid ><version>0.9</version></dependency><dependency><groupid>org.apache.mahout </groupid><artifactid>mahout-math</artifactid><version>0.9</version></ Dependency>


This article from "Wandering Footsteps" blog, declined reprint!

The mahout of recommendation engine based on user collaborative filtering 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.