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