Mahout: datamodel doesn' t have preference values

Source: Internet
Author: User

 

Mahout in action in section 3.3 coping without preference values mentions data scenarios with no preference values. 1 ~ The five-point Preference Scoring scenario is too difficult, which requires a slightly complicated value judgment process. in contrast, "TOP" and "Step" are much simpler. as shown in the figure below, the boolean data model has been simplified to "like", "dislike", and "don't know ".

The author provides a "sample code", which throws an exception when running the sample code. The author also makes it clear (p37 ).

"You shoshould find that running this code results in an illegalargumentexception from the pearsoncorrelationsimilarity constructor. this may be surprising at first: Isn't genericbooleanprefdatamodel also a datamodel, and nearly the same as genericdatamodel doesn't that it doesn't store distinct preference values? "

 

But this exception is still mentioned in the Forum: http://www.manning-sandbox.com/thread.jspa? Threadid = 41765

INFO: Processed 943 usersFeb 5, 2011 10:54:31 AM org.slf4j.impl.JCLLoggerAdapter infoINFO: Beginning evaluation using 0.9 of GenericBooleanPrefDataModel[users:1,2,3...]Exception in thread "main" java.lang.IllegalArgumentException: DataModel doesn't have preference valuesat com.google.common.base.Preconditions.checkArgument(Preconditions.java:90)at org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity.<init>(PearsonCorrelationSimilarity.java:74)at org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity.<init>(PearsonCorrelationSimilarity.java:66)at mia.recommender.ch02.RecommenderIntro$6.buildRecommender(RecommenderIntro.java:163)at org.apache.mahout.cf.taste.impl.eval.AbstractDifferenceRecommenderEvaluator.evaluate(AbstractDifferenceRecommenderEvaluator.java:124)at mia.recommender.ch02.RecommenderIntro.eg6(RecommenderIntro.java:175)at mia.recommender.ch02.RecommenderIntro.main(RecommenderIntro.java:38) 

 

In fact, you can read the author's explanation with patience. But how can you run this code? The reason is that the pearsoncorrelationsimilarity similarity algorithm is selected, which requires a preference value. Therefore, an exception "datamodel doesn't have preference values" is thrown, we only need to select an appropriate similarity algorithm (or an algorithm without preference values) to solve this problem. the following schemes are available: tanimoto coefficient algorithm and log-likelihood algorithm, which correspond to specific classes:TanimotocoefficientsimilarityAndLoglikelihoodsimilarity

 

Try it by yourself

 

The corresponding code in the mahout in action book is in the project: https://github.com/tdunning/MiA/tree/master/src/main

 

Thumbnail

 

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.