apache-spark - 从 pyspark 矩阵分解模型中检索潜在因子

Spark 和 PySpark 新手。

我正在学习协同过滤教程 here .

我能够训练模型。但是,我不知道如何访问与用户和产品对应的潜在因素(向量)。

从上面的链接复制代码的顶部:

from pyspark.mllib.recommendation import ALS, MatrixFactorizationModel, Rating

# Load and parse the data
data = sc.textFile("data/mllib/als/test.data")
ratings = data.map(lambda l: l.split(','))\
    .map(lambda l: Rating(int(l[0]), int(l[1]), float(l[2])))

# Build the recommendation model using Alternating Least Squares
rank = 10
numIterations = 10
model = ALS.train(ratings, rank, numIterations)

如何从模型中提取潜在因子?

最佳答案

尝试:

model.productFeatures()

model.productFeatures()

https://stackoverflow.com/questions/39003516/

相关文章:

sql - Firebase 与 Backendless

android - 错误你已经拥有这个项目

macos - 如何让 macOS 虚拟机以安全模式启动?

python - 如何更改seaborn jointplot中注释的字体大小?

dns - 如何让 DNS 从本地主机解析与从远程主机解析相同的内容?

macos - OSX - 已签名的安装程序被拒绝

emacs - emacs cider/paredit/clojure-mode 中的缩进配置

oracle-sqldeveloper - 我可以将我的数据源从 SQLDeveloper 导入到

modelica - 在 Dymola/Modelica 中访问经过验证的函数库(例如贝塞尔函数)

java - 使用 WebSecurityConfigurerAdapter 而不是 WebMvcC