抱歉,如果这是一个菜鸟问题,但我是 MAHOUT 的新手,我必须对 MovieLens 数据集进行一些测试。我想知道是否可以用 u1base.csv 训练推荐器,并用 u1test.csv 测试推荐器以确定准确率和召回率?
我发现的关于评估的例子他们只漏掉了数据,但我想用 u1base 来训练和 u1test 来测试。
u1base.csv 和 u1test.csv 具有相同的格式“UserId,Item,Rating”。
我有的java代码:
File userPreferencesFile = new File("u1base.csv");
File userTeste = new File("u1test.csv");
RandomUtils.useTestSeed();
DataModel dataModel = new FileDataModel(userPreferencesFile);
DataModel testModel = new FileDataModel(userTeste);
RecommenderIRStatsEvaluator recommenderEvaluator = new GenericRecommenderIRStatsEvaluator();
RecommenderBuilder recommenderBuilder = new RecommenderBuilder() {
@Override
public Recommender buildRecommender(DataModel dataModel) throws TasteException {
UserSimilarity userSimilarity = new PearsonCorrelationSimilarity(dataModel);
UserNeighborhood userNeighborhood = new NearestNUserNeighborhood(10, userSimilarity, dataModel);
return new GenericUserBasedRecommender(dataModel, userNeighborhood, userSimilarity);
}
};
IRStatistics statistics =
recommenderEvaluator.evaluate(
recommenderBuilder, null, dataModel, null, 2, GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1.0);
System.out.format("The recommender precision is %f%n", statistics.getPrecision());
System.out.format("The recommender recall is %f%n", statistics.getRecall());
}
任何帮助都感激不尽