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/