电商推荐系统设计
数据生命周期
大数据处理流程
项目系统结构
数据源
商品信息 products.csv
用户评分信息 ratings.csv
主要数据模型
统计推荐模块
历史热门商品统计
统计所有历史数据中每个商品的评分数
select productId, count(productId) as count from ratings group by productId order by count desc
RateMoreProducts
RateMoreProducts 数据结构:productId,count
近期热门商品统计
统计每月的商品评分个数,就代表了商品近期的热门度
select productId, score, changeDate(timestamp) as yearmonth from ratings
ratingOfMonth
select productId, count(productId) as count ,yearmonth from ratingOfMonth group by yearmonth, productId order by yearmonth desc,count desc
RateMoreRecentlyProducts
changDate :UDF函数,使用 SimpleDateFormat 对 Date 进行格式转化,转化格式为“yyyyMM”
RateMoreRecentlyProducts 数据结构:productId,count,yearmonth
商品平均评分统计
select productId, avg(score) as avg from ratings group by productId order by avg desc
AverageProducts
AverageProducts 数据结构:productId,avg
基于LFM的离线推荐模块
用ALS算法训练隐语义模型(LFM)
基于模型的实时推荐模块
计算速度要快
结果可以不是特别精确
有预先设计好的推荐模型
推荐优先级计算
基本原理:用户最近一段时间的口味是相似的
其他形式的离线相似推荐
怎样找到商品 A 的相似商品?—— 与A有相同标签的商品,喜欢A的人同样喜欢的商品
根据 UGC 的特征提取 —— 利用TF-IDF算法从商品内容标签中提取特征
根据行为数据的相似度计算—— Item-CF:根据行为数据,找到喜欢了商品A的用户,同时喜欢了哪些商品,喜欢的人重合度越高相似度就越大