Mahout in action分析维基百科数据例子(一)

本文来源于我个人博客www.chenbiaolong.com

概要

本文主要根据mahout in action第六章分析维基百科链接数据的例子编写。大部分内容是直接翻译的mahout in action,不过不是逐字翻译,加入了一些个人理解。关于本文的前提背景可以参考其他博主翻译的文章:
Mahout in action 中文版-6.分布式推荐计算-6.1
Mahout in action 中文版-6.分布式推荐计算-6.2

6.3.2 使用MapReduce:生成用户向量

在这个例子中,我们主要目的是利用item-base的推荐算法实现维基百科网页的推荐。基础理论就是:如果网页A和网页B同时被多个网页同时引用,那么我们就可以推测网页A和网页B的内容相近。当一个用户看了网页A时,我们可以考虑将网页B推荐给它。计算的输入文件是维基百科的链接数据文件,这个文件的每一行数据并不是按照userId,itemId,preference格式排列的,而是按照userID:itemID1 itemID2 itemID3 ...格式排列。这个格式代表的意义是ID为userID的网页有指向ID为itemID1,itemID2...网页的超链接。可以在这里获得所需要的维基百科链接数据文件。将这个文件传送到HDFS文件系统,以便Hadoop集群使用该文件。
为了实现网页推荐功能,我们需要2次的MapReduce操作。

第一次的MapReduce操作将生成用户向量:

  • 在MapReduce框架中,输入的文件将会被看成(Long,String)的键值对,Key是Long类型,它表示值在文件中的位置。String是该行具体的数据内容。比如239/98955:590 22 9059239表示数据行位于的文件位置,95955:590 22是该行的内容
  • 每一行将会被一个map函数解析为一个user ID和若干个item ID。这个map函数将会生成新的key/value对:一个user ID关联一个item ID,比如98955/590
  • 框架收集所有的被user ID关联的item ID
  • reduce函数输出user ID和与该用户对各个item的喜好向量。用户喜好向量只能为0或者1(因为链接只有有和没有2种情况)。比如95955/[590:1.0,22:1.0,9059:1.0]表示网页95955有链接到590,22,9059的超链接。需要注意的是这里userID
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
brief contents 1 ■ Meet Apache Mahout 1 PART 1 RECOMMENDATIONS ...................................................11 2 ■ Introducing recommenders 13 3 ■ Representing recommender data 26 4 ■ Making recommendations 41 5 ■ Taking recommenders to production 70 6 ■ Distributing recommendation computations 91 PART 2 CLUSTERING .............................................................115 7 ■ Introduction to clustering 117 8 ■ Representing data 130 9 ■ Clustering algorithms in Mahout 145 10 ■ Evaluating and improving clustering quality 184 11 ■ Taking clustering to production 198 12 ■ Real-world applications of clustering 210 Licensed to Jianbin Dai vi BRIEF CONTENTS PART 3 CLASSIFICATION ........................................................225 13 ■ Introduction to classification 227 14 ■ Training a classifier 255 15 ■ Evaluating and tuning a classifier 281 16 ■ Deploying a classifier 307 17 ■ Case study: Shop It To Me 341 Licensed to Jianbin Dai vii contents preface xvii acknowledgments xix about this book xx about multimedia extras xxiii about the cover illustration xxv 1 Meet Apache Mahout 1 1.1 Mahout’s story 2 1.2 Mahout’s machine learning themes 3 Recommender engines 3 ■ Clustering 3 ■ Classification 4 1.3 Tackling large scale with Mahout and Hadoop 5 1.4 Setting up Mahout 6 Java and IDEs 7 ■ Installing Maven 8 ■ Installing Mahout 8 ■ Installing Hadoop 9 1.5 Summary 9 PART 1 RECOMMENDATIONS...........................................11 2 Introducing recommenders 13 2.1 Defining recommendation 14 Licensed to Jianbin Dai viii CONTENTS 2.2 Running a first recommender engine 15 Creating the input 15 ■ Creating a recommender 16 Analyzing the output 17 2.3 Evaluating a recommender 18 Training data and scoring 18 ■ Running RecommenderEvaluator 19 ■ Assessing the result 20 2.4 Evaluating precision and recall 21 Running RecommenderIRStatsEvaluator 21 ■ Problems with precision and recall 23 2.5 Evaluating the

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值