mahout推荐3-评估查准率和查全率
2014-08-04 09:49
323 查看
通过估计偏好值来生成推荐结果并非绝对必要。给出一个从优到劣的推荐列表对于许多场景都够用了,而不必包含估计的偏好值。
查准率:在top结果中相关结果的比例
查全率:所有相关结果,包含在top结果中的比例
对上个例子进行测试:
输出结果:
文件描述:见《mahout in Action》
查准率:在top结果中相关结果的比例
查全率:所有相关结果,包含在top结果中的比例
对上个例子进行测试:
package mahout; import java.io.File; import org.apache.mahout.cf.taste.common.TasteException; import org.apache.mahout.cf.taste.eval.IRStatistics; import org.apache.mahout.cf.taste.eval.RecommenderBuilder; import org.apache.mahout.cf.taste.eval.RecommenderIRStatsEvaluator; import org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator; import org.apache.mahout.cf.taste.impl.model.file.FileDataModel; import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood; import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender; import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity; import org.apache.mahout.cf.taste.model.DataModel; import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood; import org.apache.mahout.cf.taste.recommender.Recommender; import org.apache.mahout.cf.taste.similarity.UserSimilarity; import org.apache.mahout.common.RandomUtils; public class IRStatsEvalutator { public static void main(String[] args) throws Exception { RandomUtils.useTestSeed(); DataModel dataModel = new FileDataModel(new File("data/intro.csv")); RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator(); //用于生成推荐引擎的构建器,与上一例子实现相同 RecommenderBuilder builder = new RecommenderBuilder() { public Recommender buildRecommender(DataModel model) throws TasteException { // TODO Auto-generated method stub //用户相似度,多种方法 UserSimilarity similarity = new PearsonCorrelationSimilarity(model); //用户邻居 UserNeighborhood neighborhood = new NearestNUserNeighborhood(2, similarity, model); //一个推荐器 return new GenericUserBasedRecommender(model, neighborhood, similarity); } }; //评估推荐2个结果时的查准率和查全率 IRStatistics statistics = evaluator.evaluate(builder, null, dataModel, null, 2, GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1.0); System.out.println("查准率:"+statistics.getPrecision()); System.out.println("查全率:"+statistics.getRecall()); } }
输出结果:
14/08/04 09:46:21 INFO file.FileDataModel: Creating FileDataModel for file data\intro.csv 14/08/04 09:46:21 INFO file.FileDataModel: Reading file info... 14/08/04 09:46:21 INFO file.FileDataModel: Read lines: 21 14/08/04 09:46:21 INFO model.GenericDataModel: Processed 5 users 14/08/04 09:46:21 INFO model.GenericDataModel: Processed 5 users 14/08/04 09:46:21 INFO model.GenericDataModel: Processed 5 users 14/08/04 09:46:21 INFO eval.GenericRecommenderIRStatsEvaluator: Evaluated with user 2 in 31ms 14/08/04 09:46:21 INFO eval.GenericRecommenderIRStatsEvaluator: Precision/recall/fall-out/nDCG/reach: 1.0 / 1.0 / 0.0 / 1.0 / 1.0 14/08/04 09:46:21 INFO model.GenericDataModel: Processed 5 users 14/08/04 09:46:21 INFO eval.GenericRecommenderIRStatsEvaluator: Evaluated with user 4 in 0ms 14/08/04 09:46:21 INFO eval.GenericRecommenderIRStatsEvaluator: Precision/recall/fall-out/nDCG/reach: 0.75 / 1.0 / 0.08333333333333333 / 1.0 / 1.0 查准率:0.75 查全率:1.0
文件描述:见《mahout in Action》
相关文章推荐
- mahout推荐8-利用布尔型数据评估查准率和查全率
- mahout入门之评估查准率与查全率
- mahout实现查准率和查全率评估的配置与运行
- mahout利用布尔型数据评估查准率和查全率
- 推荐系统评估 查找率与查全率
- mahout中布尔型数据推荐系统的生成与评估
- Mahout小结:关于评估推荐系统估计值与实际值的偏差出现异常:DataModel doesn't have preference values
- mahout评估一个简单的推荐程序
- mahout推荐入门之评估GroupLens数据集
- Mahout对于定制的GroupLens推荐进行评估
- mahout推荐4-评估GroupLens数据集
- 《机器学习》第二章 模型评估与选择 笔记3 查准率、查全率
- mahout入门之对推荐结果进行评估
- 利用nutch-1.2和Lucene 搭建自己的搜索平台, Apache Mahout 构建社会化推荐引擎
- 使用Mahout搭建推荐系统之入门篇1-搭建REST风格简单推荐系统
- Mahout in action 中文版-6.分布式推荐计算-6.1
- mahout in Action2.2-给用户推荐图书(1)-直观分析和代码
- mahout推荐相似度学习总结
- mahout 推荐系统示例
- Mahout基于内存的DataMode 推荐引擎Demo2