mahout主页:http://mahout.apache.org/
mahout maven:
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.9</version> </dependency>
参考:http://mahout.apache.org/users/recommender/userbased-5-minutes.html
例子:
public class TMahout01 { public static void main(String[] args) throws IOException, TasteException {
//-简单的推荐程序-// DataModel model = new FileDataModel(new File("path/dataset.csv")); UserSimilarity similarity = new PearsonCorrelationSimilarity(model); UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, model); UserBasedRecommender recommender = new GenericUserBasedRecommender(model, neighborhood, similarity); List<RecommendedItem> recommendations = recommender.recommend(2, 3); for (RecommendedItem recommendation : recommendations) { System.out.println(recommendation); } } }