gpt4 book ai didi

java - Google 先决条件非法参数异常

转载 作者:太空宇宙 更新时间:2023-11-04 07:26:35 25 4
gpt4 key购买 nike

我正在使用 mahout 为可能的应用程序创建一个基本的推荐器。我的数据集没有任何偏好。这是我的 table 的样子 enter image description here

以下是设置 mahout 的方法

  MySQLJDBCDataModel jdbcModel2 = new MySQLJDBCDataModel(dataSource,"user_viewed_song_statistics",
"AUDIO_FK","USER_PROFILE_FK","AUDIO_FK","UVSS_DATE_CREATED");


ItemSimilarity similarity = new LogLikelihoodSimilarity(jdbcModel2);
Recommender recommender =
new GenericBooleanPrefItemBasedRecommender(jdbcModel2, similarity);

for(RecommendedItem item: recommender.recommend(1, 1))
System.out.println(item);

但是运行之后。它返回了这个错误

Exception in thread "main" java.lang.IllegalArgumentException
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:72)
at org.apache.mahout.math.stats.LogLikelihood.logLikelihoodRatio(LogLikelihood.java:101)
at org.apache.mahout.cf.taste.impl.similarity.LogLikelihoodSimilarity.doItemSimilarity(LogLikelihoodSimilarity.java:102)
at org.apache.mahout.cf.taste.impl.similarity.LogLikelihoodSimilarity.itemSimilarities(LogLikelihoodSimilarity.java:90)
at org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefItemBasedRecommender.doEstimatePreference(GenericBooleanPrefItemBasedRecommender.java:54)
at org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender$Estimator.estimate(GenericItemBasedRecommender.java:312)
at org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender$Estimator.estimate(GenericItemBasedRecommender.java:300)
at org.apache.mahout.cf.taste.impl.recommender.TopItems.getTopItems(TopItems.java:65)
at org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender.recommend(GenericItemBasedRecommender.java:131)
at org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender.recommend(AbstractRecommender.java:63)
at Starter.main(Starter.java:53)

最佳答案

您正在使用非偏好项目推荐。类似这个question

我确实发现它返回这种类型的异常很奇怪。我所做的就是这样的。

MySQLBooleanPrefJDBCDataModel jdbc = new MySQLBooleanPrefJDBCDataModel(dataSource, TABLE_NAME, USER_ID, ITEM_ID);
CachingRecommender cachingRecommender = new CachingRecommender( new SlopeOneRecommender(jdbc));

// Get 5 recommendations for user 3
List<RecommendedItem> items = cachingRecommender.recommend(3, 5);
for (RecommendedItem item : items) {
System.out.println(item);
}

希望这有帮助。

关于java - Google 先决条件非法参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18448189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com