`

Mahout: distributed item-based algorithm 3

 
阅读更多

Running recommendations with Hadoop

The glue that binds together the various Mapper and Reducer components is org.apache.mahout.cf.taste.hadoop.item.RecommenderJob. It configures and invokes the series of MapReduce jobs discussed previously. These MapReduces and their relationships are illustrated below:




Run the example with wikipida data

bin/hadoop fs -put links-simple-sorted.txt input/input.txt

bin/hadoop fs -put users.txt input/users.txt
In order to run RecommenderJob , and allow Hadoop to run these jobs, you need to combine all of this code into one JAR file, along with all of the code it depends upon.This can be accomplished easily by running mvn clean package from the core/ directory in the Mahout distribution—this will produce a file like mahout-core-0.5-job.jar. Or you can use a precompiled job JAR from Mahout’s distribution.
hadoop jar mahout-core-0.5-job.jar \
org.apache.mahout.cf.taste.hadoop.item.RecommenderJob \
-Dmapred.input.dir=input/input.txt \
-Dmapred.output.dir=output --usersFile input/users.txt --booleanData

 

NOTE

The obove command will not run the example codes in <<Mahout In Action>> Ch.06 instead using default related codes in mahout. So I thought this is the big drawback in this book. To run the example codes in Ch.06, you should recreate a project based on org.apache.mahout.cf.taste.hadoop.xxxx in mahout-core project and alter some codes.

 

OR 

Using Tool class WikipediaDataConverter in the example codes to convert links-simple-sorted.txt to the default input format userid, itemid. Then using the obove commands to run it. But this way will hide all in the cover that you learned from the Ch.06. So the best way is to recreate a new project to run the example codes.

 

------------------

How to alter the codes shows as below:

org.apache.mahout.cf.taste.hadoop.preparation.PreparePreferenceMatrixJob

 

//convert items to an internal index
    Job itemIDIndex = prepareJob(getInputPath(), getOutputPath(ITEMID_INDEX), 
                         TextInputFormat.class, ItemIDIndexMapper.class,
                         VarIntWritable.class, VarLongWritable.class, 
                         ItemIDIndexReducer.class, VarIntWritable.class, 
                         VarLongWritable.class, SequenceFileOutputFormat.class);
    itemIDIndex.setCombinerClass(ItemIDIndexReducer.class);

 =====>

//convert items to an internal index
    Job itemIDIndex = prepareJob(getInputPath(), getOutputPath(ITEMID_INDEX), 
                         TextInputFormat.class, WikipediaItemIDIndexMapper.class,
                         VarIntWritable.class, VarLongWritable.class, 
                         ItemIDIndexReducer.class, VarIntWritable.class, 
                         VarLongWritable.class, SequenceFileOutputFormat.class);
    itemIDIndex.setCombinerClass(ItemIDIndexReducer.class);

 --

 

 //convert user preferences into a vector per user
    Job toUserVectors = prepareJob(getInputPath(),
                                   getOutputPath(USER_VECTORS),
                                   TextInputFormat.class,
                                   ToItemPrefsMapper.class,
                                   VarLongWritable.class,
                                   booleanData ? VarLongWritable.class : EntityPrefWritable.class,
                                   ToUserVectorsReducer.class,
                                   VarLongWritable.class,
                                   VectorWritable.class,
                                   SequenceFileOutputFormat.class);
 =====>

 

 //convert user preferences into a vector per user
    Job toUserVectors = prepareJob(getInputPath(),
                                   getOutputPath(USER_VECTORS),
                                   TextInputFormat.class,
                                   WikipediaToItemPrefsMapper.class,
                                   VarLongWritable.class,
                                   booleanData ? VarLongWritable.class : EntityPrefWritable.class,
                                   WikipediaToUserVectorReducer.class,
                                   VarLongWritable.class,
                                   VectorWritable.class,
                                   SequenceFileOutputFormat.class);

 

 

 

 

Run samples on hadoop

Env: mahout 0.9   hadoop2.3.0

mvn  clean package -Dhadoop2.version=2.3.0 -DskipTests

mvn  clean package -Dhadoop.version=2.3.0 -DskipTests

 

 

 

 

 

 References

https://www.ibm.com/developerworks/library/j-mahout/

  • 大小: 70.2 KB
分享到:
评论

相关推荐

    apache-mahout-distribution-0.11.0-src.zip

    在"apache-mahout-distribution-0.11.0-src.zip"这个压缩包中,您将找到Mahout 0.11.0版本的源代码,这对于开发者和研究者来说是一个宝贵的资源,他们可以深入理解算法的内部工作原理,进行定制化开发或优化。...

    Mahout之Item-based应用使用

    在这个主题中,我们将深入探讨Mahout中的Item-based协同过滤(Item-based Collaborative Filtering)方法,这是一种在推荐系统中广泛使用的算法,用于预测用户可能对哪些项目感兴趣。 协同过滤是一种基于用户行为的...

    如何成功运行Apache Mahout的Taste Webapp-Mahout推荐教程-Maven3.0.5-JDK1.6-Mahout0.5

    在Mahout Taste Webapp工程中,需要添加对mahout-examples的依赖,这一步骤是必须的,因为示例代码提供了实际运行推荐系统所必需的组件。 6. 配置推荐引擎的属性 在Mahout Taste Webapp的recommender.properties...

    mahout-core-0.9.jar+mahout-core-0.8.jar+mahout-core-0.1.jar

    这个压缩包包含的是Mahout项目不同版本的核心库,分别是mahout-core-0.9.jar、mahout-core-0.8.jar和mahout-core-0.1.jar。这些版本的差异在于功能的完善、性能的优化以及对新特性的支持。 1. **Mahout核心功能**:...

    mahout-distribution-0.9.tar.gz

    1. **推荐系统**:Mahout提供了多种协同过滤算法,如User-Based和Item-Based推荐,以及矩阵分解技术如SVD(奇异值分解)和ALS(交替最小二乘法),这些算法常用于电商、音乐、视频等领域的个性化推荐。 2. **分类与...

    mahout:mahout-推荐-测试

    在 Mahout 中,推荐系统主要分为两种类型:基于用户的协同过滤(User-Based Collaborative Filtering)和基于物品的协同过滤(Item-Based Collaborative Filtering)。前者通过找到具有相似购买或评分历史的用户来...

    mahout-distribution-0.8-src

    在Mahout-distribution-0.8-src这个源代码包中,我们可以深入理解其内部机制,同时也为开发者提供了实现自定义机器学习模型的可能。 一、Mahout 0.8概览 Mahout 0.8 版本是该项目的一个重要里程碑,它包含了丰富的...

    apache-mahout-distribution-0.11.1-src

    Apache Mahout 项目旨在帮助开发人员更加方便快捷地创建智能应用程序。Mahout 的创始者 Grant Ingersoll 介绍了机器学习的基本概念,并演示了如何使用 Mahout 来实现文档集群、提出建议和组织内容。

    mahout-distribution-0.9含jar包

    1. **推荐系统**:Mahout提供了多种协同过滤算法,如User-Based和Item-Based,用于实现个性化推荐。这些算法能够分析用户的历史行为数据,预测他们可能感兴趣的新内容,从而提升用户体验。 2. **分类**:Mahout支持...

    mahout-distribution-0.9-src.zip

    标题中的"mahout-distribution-0.9-src.zip"指的是Mahout项目在0.9版本的源代码分布,这对于开发者来说是一个宝贵的资源,可以深入理解其内部实现并进行定制化开发。 Apache Mahout的核心特性主要体现在以下几个...

    maven_mahout_template-mahout-0.8

    《Apache Maven与Mahout实战:基于maven_mahout_template-mahout-0.8的探索》 Apache Maven是一款强大的项目管理和依赖管理工具,广泛应用于Java开发领域。它通过一个项目对象模型(Project Object Model,POM)来...

    mahout-examples-0.9-job.jar(修改版)

    重新编译mahout-examples-0.9-job.jar,增加分类指标:最小最大精度、召回率。详情见http://blog.csdn.net/u012948976/article/details/50203249

    mahout-distribution-0.7-src.zip

    2. 解压`mahout-distribution-0.7-src.zip`文件到本地目录。 3. 进入解压后的源码目录,执行`mvn clean install`命令进行编译。这会下载依赖项,构建Mahout的jar包。 4. 编译完成后,可以在`target`目录下找到编译...

    mahout所需jar包

    在给定的压缩包中,包含了`mahout-distribution-0.5`版本,这个版本的Mahout已经包含了运行K-Means所需的所有jar包,用户可以直接使用而无需自行编译。 **使用Mahout的步骤** 1. **配置环境**:确保已经安装了Java...

    mahout-core-0.3.jar

    mahout中需要用到的一个版本jar包:mahout-core-0.3.jar

    Apache_Mahout_Cookbook(高清版)

    &lt;artifactId&gt;mahout-core &lt;version&gt;0.13.0 ``` #### 三、使用Sequence Files ##### 3.1 创建Sequence Files **知识点:** - **Sequence Files**:Hadoop的二进制文件格式,适合大数据存储。 - **命令行工具**...

    mahout-distribution-0.5-src.zip mahout 源码包

    mahout-distribution-0.5-src.zip mahout 源码包

    mahout-integration-0.7

    mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7

    mahout-distribution-0.12.2-src.tar.gz

    3. **源代码结构**:在源代码目录下,你可以看到不同模块的实现,例如`math`包含了基础数学运算,`distributed`包含了与Hadoop相关的代码,`examples`提供了算法应用实例,而`src/main/scala`包含了用Scala编写的...

Global site tag (gtag.js) - Google Analytics