mahout实现查准率和查全率评估的配置与运行
2015-05-04 16:41
274 查看
/* * 查准率和查全率评估的配置与运行 * * */ package byuser; 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 RecommenderIRStatsEvaluatorTest { public RecommenderIRStatsEvaluatorTest(){ try{ RandomUtils.useTestSeed(); DataModel model = new FileDataModel(new File("E:\\mahout项目\\examples\\intro.csv")); RecommenderIRStatsEvaluator evaluator = new GenericRecommenderIRStatsEvaluator(); RecommenderBuilder recommenderBuilder = new RecommenderBuilder() { @Override 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); } }; //推荐两个数据 IRStatistics stats = evaluator.evaluate(recommenderBuilder, null, model, null, 2, GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD, 1.0); System.out.println("推荐两个结果的查准率 :" + stats.getPrecision()); System.out.println("推荐两个结果的查全率 :" + stats.getRecall()); }catch(Exception e){ e.printStackTrace(); } } public static void main(String[] args) { // TODO Auto-generated method stub RecommenderIRStatsEvaluatorTest test = new RecommenderIRStatsEvaluatorTest(); } }
结果:
相关文章推荐
- mahout入门之评估查准率与查全率
- mahout利用布尔型数据评估查准率和查全率
- mahout推荐8-利用布尔型数据评估查准率和查全率
- mahout推荐3-评估查准率和查全率
- windows server,nginx安装,配置,运行nodeJS后端的web项目的实现,以及错误分析及解决方法
- php 计算程序运行时间的类,以及用它和Curl结合Host,实现不用配置Host得到该测试机的访问速度。
- mahout安装配置,运行kmeans算法,bin/mahout -help出现MAHOUT_LOCAL is not set; adding HADOOP_CONF_DIR to classpath
- seetaface在嵌入式平台的性能评估以及windows版配置运行
- 实现一个支持运行时并发修改配置生效的Configuration类
- 利用Mahout实现在Hadoop上运行K-Means算法
- REMODE+ORBSLAM运行配置(2) REMODE和编译后的ORB ros工程利用节点实现通讯
- Hibernate断网修改配置文件实现正常验证运行
- 利用Mahout实现在Hadoop上运行K-Means算法
- Sublime Java 环境配置-实现Java程序编译、运行
- java实现串口配置之运行环境搭建
- 利用Mahout实现在Hadoop上运行K-Means算法
- jsp servlet mysql实现的学生成绩管理系统源码附带视频指导配置运行教程
- php 计算程序运行时间的类,以及用它和Curl结合Host,实现不用配置Host得到该测试机的访问速度。
- mahout0.6-hadoop1.1.2安装配置及运行kmeans聚类算法
- 在Windows下配置vim结合MinGW以实现gcc、g++编译运行和调试