原文链接:
《基于 Apache Mahout 构建社会化推荐引擎》--http://www.ibm.com/developerworks/cn/java/j-lo-mahout/
这段时间学习推荐系统,发现了这篇不错的文章,按照文章中的执行难,发现原文中有些步骤执行不了,写的不详细,遇到的问题记录了下来,先记录第一步,运行例子,具体执行步骤:
安装JDK、Maven、tomcat、cygwin,并添加是环境变量。
svn地址:http://svn.apache.org/repos/asf/mahout/tags/mahout-0.5/
http://www.grouplens.org/datasets/movielens/
3. 解压数据源压缩包,将 movie.dat 和 ratings.dat 拷贝到 Mahout 安装目录下的 taste-web/src/ main/resources/org/apache/mahout/cf/taste/example/grouplens 目录下。
4. 在 core 目录下,运行 mvn install
5. 在 examples 目录下,运行 mvn install,在examples目录中的target中得到grouplens.jar
6. 进入taste-web中,拷贝 ../examples/target/grouplens.jar 到 taste-web/lib 目录,修改properties文件,去掉注释
recommender.class=org.apache.mahout.cf.taste.example.grouplens.GroupLensRecommender
7. 在 taste-web 的目录下,运行"mvn package",将taste-web打包成war包。
其他说明:
//需要设置一下tomcat的jvm内存,否则报java.lang.OutOfMemoryError: Java heap space。Windows 设置1024M的jvm内存的方法是在catalina.bat的第一行前加入set JAVA_OPTS=-Xms512m -Xmx1024m
//如果多次mvn install 不成功,提示同一个错误,试试mvn -U install。
In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure. To force a refresh add -U to the command line.
C:\cygwin\bin;C:\cygwin\usr\sbin;
//mvn install 编译core时间特别长,耐心等待
//编译成功输出:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20:59.453s
[INFO] Finished at: Fri Nov 29 10:46:23 CST 2013
[INFO] Final Memory: 8M/29M
[INFO] ------------------------------------------------------------------------
//访问路径
http://localhost/mahout-taste-webapp-0.5/RecommenderServlet?userID=1
http://localhost/mahout-taste-webapp-0.5/RecommenderService.jws?wsdl
http://localhost/mahout-taste-webapp-0.5/RecommenderService.jws?method=recommend&userID=1&howMany=10
//截图
另外,已经将打好的war包上传至资源,地址: