Mahout Learning (1)

Source: Internet
Author: User

Mahout home: http://mahout.apache.org/

Mahout Maven:

<dependency>    <groupId>org.apache.mahout</groupId>    <artifactId>mahout-core</artifactId>    <version>0.9</version></dependency>

Reference: http://mahout.apache.org/users/recommender/userbased-5-minutes.html

Example:

public class TMahout {    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);        }        RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();        RecommenderBuilder builder = new RecommenderBuilder() {            @Override            public Recommender buildRecommender(DataModel dataModel) throws TasteException {                UserSimilarity similarity = new PearsonCorrelationSimilarity(dataModel);                UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, dataModel);                return new GenericUserBasedRecommender(dataModel, neighborhood, similarity);            }        };        double result = evaluator.evaluate(builder, null, model, 0.9, 1.0);        System.out.println(result);    }}

 

Mahout Learning (1)

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.