jasonwiki / recommend Goto Github PK
View Code? Open in Web Editor NEW基于 spark 推荐系统, 基于内容标签 CBCF 实现,协同过滤 UBCF 实现,协同过滤 IBCF 实现
基于 spark 推荐系统, 基于内容标签 CBCF 实现,协同过滤 UBCF 实现,协同过滤 IBCF 实现
1、函数式编程需要加强,通过看代码看出来还是比较熟悉Java而可能刚接触Scala。
2、RDD操作带来的效率问题需要斟酌提高。
比如在UBCF.scala文件中,在生成user->user矩阵中先用到了groupBy(),然后在合并中用到了reduce(),这是两段代码比较累赘。scala中尽量不要用var,并且对RDD的操作不需要map。
下面是按照你的代码个人的修改的一些想法(两段代码合并为一段),也不能说一定是最好的,只是共同学习。
val userMatrixsRDD = itemsUserCollectionRDD.groupBy(_.1).flatMap(
x =>
for (
ri <- x._2.iterator;
rj <- x._2.iterator
if ri.id < rj.id
)
yield {
((ri.id, rj.id), 1L
}
)
val userAndUserMatrixCollection = userMatrixsRDD
.reduceByKey((x, y) => x + y)
.map { x =>
val ((uid, vid), counts) = x
(uid, vid, similarity(uid, vid, counts) // similarity是自定义计算相似度的函数
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.