SlideShare ist ein Scribd-Unternehmen logo
1 von 25
矩阵方法在推荐系统中的
应用
肖镜辉
涉及到的模型
• LR – logistic regression
• SVM – support vector machine
• SVD – singular value
decomposition
• SVD++
• CF – collaborative filtering
• MF – matrix factorization
• NMF – non-negative MF
• PCA – principal component analysis
• FM – factorization machine
• FFM – field-aware FM
• LSI – latent sematic index
• PLSA – probability latent semantic
analysis
• LDA – latent dirichlet allocation
推荐系统问题转化
• 推荐系统问题:
• 给user推荐item,基于但不限于如下依据:user历史行为、item属性、推
荐场景、推荐时机、其它user的行为、其它item……
• 问题转化:
• 计算Score(user, item)并排序
• 思路:
• 回归派:转化为回归问题,e.g. ctr预估
• 矩阵派:user-item矩阵变换,e.g.协同过滤
• 排序派:Learn2rank
矩阵基础 之 PCA
• 目的:数据降维,找到描述数据的‘主要方向’
• 例子:
‘语文’分数对学生群体没有区分度
矩阵基础 之 PCA cont
• 方法:找到一组标准正交基(相互无关的向量组),每个样本表
示为这组正交基的线性组合
矩阵基础 之 PCA cont
• 如何找到B和V?
• 总体:矩阵的线性变换得到
• 具体:
• 如何刻画‘不相关’?——协方差矩阵
• Step1: V是ATA的特征矩阵
• Step2: B=AV
矩阵基础 之 SVD
• 方法:将user-item矩阵分解为三个矩阵的乘积,user矩阵、item
矩阵和特征值矩阵
• 目的:压缩、降噪
矩阵基础 之 SVD cont
原始图片(450*333) 保留1个奇异值 保留5个奇异值 保留20个奇异值
矩阵基础 之 SVD cont
• 如何找到U、sigma、V?
• 总体:矩阵的线性变换得到
• 具体:
• 如何刻画‘不相关’?——协方差矩阵
• ……
回归派 之 LR
• 通用线性回归模型
• score = weight1 * input1 + weight2 * input2 + ......
• 逻辑回归模型
• Score是‘比率’
• score=log( p(y=1|x) / p(y=0|x) )  sigmoid函数形式
• 逆向思考一下
• 当我们需要把(-∞, +∞)投影到概率区间[0.0, 1.0]的时候,想想sigmoid函数
• 注意,当[-5,5]的时候,sigmoid取值已经接近于0和1,缩放?
LR vs SVM
• Svm是高维空间的LR
• 注意1:不仅仅是‘weight1 * input1’增加维度,某些核函数会有特征组
合的效果,即‘weight_12 * <input1, input2>’,所以svm加入和非线性,
描述能力强于线性的LR
• 注意2:‘核函数’不仅增加了描述能力,而且避免了维数灾(dim curse)
• Svm的‘结构风险最小化’——L1或L2正则
• 实际分类的时候用‘支持向量’而不是模型参数——基于实例的
方法
• 训练的时候需要load所有样本
矩阵派 之 CF(collaborative filtering)
• 目标问题:user-item矩阵
• 思路:kNN
• 方法:
• User-based:k个user近邻
• Item-based:k个item近邻
• User-based vs Item-based
• 适用场景:Item-based适用item数量远低于user数量的,e.g. 电影推荐
• 局限:Item-based结果的多样性不好
• 哲学思想:基于‘社区’的推荐(user-based)
• 实操注意:
• 数据预处理很重要
矩阵派 之 MF(Matrix Factorization)
• CF存在的问题:
• kNN,k的取值?--- 再大也是‘局部’信息
• User-item矩阵非常稀疏,kNN结果也不见得准确
• 回顾‘矩阵派’的思路:
• 面对User-item这个大的稀疏矩阵,将矩阵中‘未知值’进行估计、填满
• MF的思路:
• 原始user-item矩阵分解
• 用子矩阵还原user-item矩阵
• 还原后的user-item矩阵,不存在‘未知值’,位置<user, item>的值就是
对user是否喜欢item的预测
矩阵派 之 MF cont
• MF思路 之 SVD
• 用SVD来进行矩阵分解,取有限个特征值(去噪),然后进行矩阵还原
• MF思路 之 SGD
• 不去管矩阵中的‘未知值’
• 以MSE为学习目标,用SGD去尽量拟合user-item中的已知值
• NMF: non-negative matrix factorization,非负矩阵分解
• 定理:总能找到这种分解
• 寻找的过程是NP-hard问题
回归派与矩阵派的合体 之 RSVD、SVD++ ……
• 回顾回归派之LR
• score = weight1 * input1 + weight2 * input2 + ......
• 回顾矩阵派之MF
• 以MSE为学习目标,用SGD去尽量拟合user-item中的已知值
• 相当于:Score_user(i)_item(j) = weight(i) * user(i) + weight(j) * item(j)
• ‘回归派’和‘矩阵派’在这里融合了
• 接下来
• 对Score_user(i)_item(j) 中user和item加正则项 —— R(regression)SVD
• 考虑用户浏览过、但未评分的行为 —— A(asymmetric)SVD
• 简化ASVD——SVD++
回归派 之 FM(factorization machine)
• Why here?
• 前向基础知识 之 矩阵分解
• 前向基础知识 之 回归派
• What is FM
• 增强版的LR,加入了组合特征
• E.g. degree == 2
• score = weight1 * input1 + weight2 * input2 + ......+ weight_1_2 * <input1, input2> + ……
• Weight_1_2的数量?N^2
• 参数大幅增加,训练样本极度稀疏,咋办?
回归派 之 FM cont
• weight_i_j分解为k维向量的内积
——增大k,提升拟合性能;减小k,提升泛化性能
回归派 之 FM cont
• 理论保证
• 存在这样的分解,能够逼近原始矩阵
• 计算代价
• 实际应用的时候,并不需要计算向量内积;线性时间复杂度
• 训练方法
• SGD
• 工具包
• libFM
• 扩展
• FFM(field-aware factorization machine)
FM vs SVM
• 共同点
• 2-d FM相当于采用2-d多项式核的svm
• 区别
• Svm, 不同weight_i_j之间是相互独立的,需要分别估计,存在数据稀疏
问题
• FM, weight_i_j的值与weight_i和weight_j有关,类似利用‘边缘概率’
来拟合‘联合概率’,能更好的处理数据稀疏问题
矩阵方法在NLP的应用 之 LSI
• LSI(latent semantic index)or LSA( latent semantic analysis)
• 思路
• Word-doc矩阵
• 类似MF处理方法
• SVD分解选取奇异值(去噪)还原word-doc矩阵
• 应用
• 文本分类、聚类
矩阵方法在NLP的应用 之 pLsa
• pLsa(probability latent semantic analysis)
• 思路
• 引入topic概念:word-doc  word-topic-doc
• word-doc矩阵分解Word-topic子阵、doc-topic子阵
• 应用
• 相当于word和doc的embedding表示
• 词聚类
• Word-topic中的topic自成聚类结果、或者用cosine等方法计算word向量间的关系
• 文章聚类
• 作为其它模型的输入特征,e.g. LR for CTR
矩阵方法在NLP的应用 之 LDA
• LDA(latent Dirichlet allocation)
• 贝叶斯学派的胜利
• 任何事物都有一个‘先验分布’,都需要对先验分布进行假设建模
• pLsa中的topic概率分布也服从某种先验分布(没错,概率分布的分布)
• 假设这种分布是Dirichlet分布
• LDA模型闪亮登场
• 然并卵
• 模型接口(输入、输出)、应用场景,与plsa并无二致
• 模型扩展
• LDA是生成模型,修改生成过程,以融入更多信息
• 并行化
• Unigram model
• LSI
• PLSA
• LDA
LSI vs PLSA vs LDA
“加餐”:RBM与推荐
• What is RBM?
• Auto-encoder
• 如何应用在推荐系统中?
• 用户实际评分  auto-encoder  预测评分
• 回顾矩阵类方法MF
• 用户实际评分(矩阵)矩阵分解和去噪预测评分(矩阵)
Thanks 

Weitere ähnliche Inhalte

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

矩阵方法在推荐系统中的应用-肖镜辉-精简

  • 2. 涉及到的模型 • LR – logistic regression • SVM – support vector machine • SVD – singular value decomposition • SVD++ • CF – collaborative filtering • MF – matrix factorization • NMF – non-negative MF • PCA – principal component analysis • FM – factorization machine • FFM – field-aware FM • LSI – latent sematic index • PLSA – probability latent semantic analysis • LDA – latent dirichlet allocation
  • 3. 推荐系统问题转化 • 推荐系统问题: • 给user推荐item,基于但不限于如下依据:user历史行为、item属性、推 荐场景、推荐时机、其它user的行为、其它item…… • 问题转化: • 计算Score(user, item)并排序 • 思路: • 回归派:转化为回归问题,e.g. ctr预估 • 矩阵派:user-item矩阵变换,e.g.协同过滤 • 排序派:Learn2rank
  • 4. 矩阵基础 之 PCA • 目的:数据降维,找到描述数据的‘主要方向’ • 例子: ‘语文’分数对学生群体没有区分度
  • 5. 矩阵基础 之 PCA cont • 方法:找到一组标准正交基(相互无关的向量组),每个样本表 示为这组正交基的线性组合
  • 6. 矩阵基础 之 PCA cont • 如何找到B和V? • 总体:矩阵的线性变换得到 • 具体: • 如何刻画‘不相关’?——协方差矩阵 • Step1: V是ATA的特征矩阵 • Step2: B=AV
  • 7. 矩阵基础 之 SVD • 方法:将user-item矩阵分解为三个矩阵的乘积,user矩阵、item 矩阵和特征值矩阵 • 目的:压缩、降噪
  • 8. 矩阵基础 之 SVD cont 原始图片(450*333) 保留1个奇异值 保留5个奇异值 保留20个奇异值
  • 9. 矩阵基础 之 SVD cont • 如何找到U、sigma、V? • 总体:矩阵的线性变换得到 • 具体: • 如何刻画‘不相关’?——协方差矩阵 • ……
  • 10. 回归派 之 LR • 通用线性回归模型 • score = weight1 * input1 + weight2 * input2 + ...... • 逻辑回归模型 • Score是‘比率’ • score=log( p(y=1|x) / p(y=0|x) )  sigmoid函数形式 • 逆向思考一下 • 当我们需要把(-∞, +∞)投影到概率区间[0.0, 1.0]的时候,想想sigmoid函数 • 注意,当[-5,5]的时候,sigmoid取值已经接近于0和1,缩放?
  • 11. LR vs SVM • Svm是高维空间的LR • 注意1:不仅仅是‘weight1 * input1’增加维度,某些核函数会有特征组 合的效果,即‘weight_12 * <input1, input2>’,所以svm加入和非线性, 描述能力强于线性的LR • 注意2:‘核函数’不仅增加了描述能力,而且避免了维数灾(dim curse) • Svm的‘结构风险最小化’——L1或L2正则 • 实际分类的时候用‘支持向量’而不是模型参数——基于实例的 方法 • 训练的时候需要load所有样本
  • 12. 矩阵派 之 CF(collaborative filtering) • 目标问题:user-item矩阵 • 思路:kNN • 方法: • User-based:k个user近邻 • Item-based:k个item近邻 • User-based vs Item-based • 适用场景:Item-based适用item数量远低于user数量的,e.g. 电影推荐 • 局限:Item-based结果的多样性不好 • 哲学思想:基于‘社区’的推荐(user-based) • 实操注意: • 数据预处理很重要
  • 13. 矩阵派 之 MF(Matrix Factorization) • CF存在的问题: • kNN,k的取值?--- 再大也是‘局部’信息 • User-item矩阵非常稀疏,kNN结果也不见得准确 • 回顾‘矩阵派’的思路: • 面对User-item这个大的稀疏矩阵,将矩阵中‘未知值’进行估计、填满 • MF的思路: • 原始user-item矩阵分解 • 用子矩阵还原user-item矩阵 • 还原后的user-item矩阵,不存在‘未知值’,位置<user, item>的值就是 对user是否喜欢item的预测
  • 14. 矩阵派 之 MF cont • MF思路 之 SVD • 用SVD来进行矩阵分解,取有限个特征值(去噪),然后进行矩阵还原 • MF思路 之 SGD • 不去管矩阵中的‘未知值’ • 以MSE为学习目标,用SGD去尽量拟合user-item中的已知值 • NMF: non-negative matrix factorization,非负矩阵分解 • 定理:总能找到这种分解 • 寻找的过程是NP-hard问题
  • 15. 回归派与矩阵派的合体 之 RSVD、SVD++ …… • 回顾回归派之LR • score = weight1 * input1 + weight2 * input2 + ...... • 回顾矩阵派之MF • 以MSE为学习目标,用SGD去尽量拟合user-item中的已知值 • 相当于:Score_user(i)_item(j) = weight(i) * user(i) + weight(j) * item(j) • ‘回归派’和‘矩阵派’在这里融合了 • 接下来 • 对Score_user(i)_item(j) 中user和item加正则项 —— R(regression)SVD • 考虑用户浏览过、但未评分的行为 —— A(asymmetric)SVD • 简化ASVD——SVD++
  • 16. 回归派 之 FM(factorization machine) • Why here? • 前向基础知识 之 矩阵分解 • 前向基础知识 之 回归派 • What is FM • 增强版的LR,加入了组合特征 • E.g. degree == 2 • score = weight1 * input1 + weight2 * input2 + ......+ weight_1_2 * <input1, input2> + …… • Weight_1_2的数量?N^2 • 参数大幅增加,训练样本极度稀疏,咋办?
  • 17. 回归派 之 FM cont • weight_i_j分解为k维向量的内积 ——增大k,提升拟合性能;减小k,提升泛化性能
  • 18. 回归派 之 FM cont • 理论保证 • 存在这样的分解,能够逼近原始矩阵 • 计算代价 • 实际应用的时候,并不需要计算向量内积;线性时间复杂度 • 训练方法 • SGD • 工具包 • libFM • 扩展 • FFM(field-aware factorization machine)
  • 19. FM vs SVM • 共同点 • 2-d FM相当于采用2-d多项式核的svm • 区别 • Svm, 不同weight_i_j之间是相互独立的,需要分别估计,存在数据稀疏 问题 • FM, weight_i_j的值与weight_i和weight_j有关,类似利用‘边缘概率’ 来拟合‘联合概率’,能更好的处理数据稀疏问题
  • 20. 矩阵方法在NLP的应用 之 LSI • LSI(latent semantic index)or LSA( latent semantic analysis) • 思路 • Word-doc矩阵 • 类似MF处理方法 • SVD分解选取奇异值(去噪)还原word-doc矩阵 • 应用 • 文本分类、聚类
  • 21. 矩阵方法在NLP的应用 之 pLsa • pLsa(probability latent semantic analysis) • 思路 • 引入topic概念:word-doc  word-topic-doc • word-doc矩阵分解Word-topic子阵、doc-topic子阵 • 应用 • 相当于word和doc的embedding表示 • 词聚类 • Word-topic中的topic自成聚类结果、或者用cosine等方法计算word向量间的关系 • 文章聚类 • 作为其它模型的输入特征,e.g. LR for CTR
  • 22. 矩阵方法在NLP的应用 之 LDA • LDA(latent Dirichlet allocation) • 贝叶斯学派的胜利 • 任何事物都有一个‘先验分布’,都需要对先验分布进行假设建模 • pLsa中的topic概率分布也服从某种先验分布(没错,概率分布的分布) • 假设这种分布是Dirichlet分布 • LDA模型闪亮登场 • 然并卵 • 模型接口(输入、输出)、应用场景,与plsa并无二致 • 模型扩展 • LDA是生成模型,修改生成过程,以融入更多信息 • 并行化
  • 23. • Unigram model • LSI • PLSA • LDA LSI vs PLSA vs LDA
  • 24. “加餐”:RBM与推荐 • What is RBM? • Auto-encoder • 如何应用在推荐系统中? • 用户实际评分  auto-encoder  预测评分 • 回顾矩阵类方法MF • 用户实际评分(矩阵)矩阵分解和去噪预测评分(矩阵)