我已经按照本教程进行了操作:
https://ademsha.com/notes/developing-recommendation-system-with-apache-mahout/
它在ml-100k数据集中运行良好,但是当我向u.data
文件添加更多评估时(使用完全相同的格式userId, itemId, rating, timestamp
),我收到以下错误:
[main] INFO org.apache.mahout.cf.taste.impl.model.file.FileDataModel - Creating FileDataModel for file u.data
Exception in thread "main" java.lang.IllegalArgumentException: Did not find a delimiter in first line
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.determineDelimiter(FileDataModel.java:351)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:201)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:169)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:149)
at teste.HelloMaven.SimpleRec.main(SimpleRec.java:20)
代码是这样的:
public class SimpleRec {
public static void main(String[] args) throws Exception {
DataModel model = new FileDataModel(new File("u.data"));
UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.5, similarity, model);
Recommender recommender = new GenericUserBasedRecommender(model,neighborhood, similarity);
List<RecommendedItem> recomendations = recommender.recommend(943,5);
for (RecommendedItem recomendation : recomendations) {
System.out.println(recomendation);
}
}
}