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