机器学习算法实践:矩阵分解、云端部署与基础工具使用
一、R语言实现矩阵分解
在推荐系统领域,矩阵分解是一种重要的技术,相较于协同过滤,它计算量更小且通常能提供更好的结果。下面将介绍如何使用R语言中的 recommenderlab 包实现矩阵分解。
1.1 导入相关包和数据集
# Matrix factorization
t=read.csv("D:/book/Recommender systems/movie_rating.csv")
library(reshape2)
library(recommenderlab)
1.2 数据预处理
t2=acast(t,critic~title)
t2
# Convert it as a matrix
R<-as.matrix(t2)
# Convert R into realRatingMatrix data structure
# RealRatingMatrix is a recommenderlab sparse-matrix like data-structure
r <- as(R, "realRatingMatrix")
1.3 使用funkSVD函数构建矩阵因子
fsvd <- funkSVD(r, k=2,verbose = TRUE)
p <- predict(fsvd, r, verbo
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



