【发布时间】:2020-07-04 22:35:51
【问题描述】:
我正在关注 ALS 的 sparkR 示例:
# Load training data
data <- list(list(0, 0, 4.0), list(0, 1, 2.0), list(1, 1, 3.0),
list(1, 2, 4.0), list(2, 1, 1.0), list(2, 2, 5.0))
df <- createDataFrame(data, c("userId", "movieId", "rating"))
training <- df
test <- df
# Fit a recommendation model using ALS with spark.als
model <- spark.als(training, maxIter = 5, regParam = 0.01, userCol = "userId",
itemCol = "movieId", ratingCol = "rating")
# Model summary
summary(model)
# Prediction
predictions <- predict(model, test)
head(predictions)
效果很好,但我遇到了以下问题:
如何指定要推荐的商品数量?
在python示例中很清楚:
movieSubSetRecs = model.recommendForItemSubset(movies, 10)
但对于 sparkR,我没有找到。
另外,我不能换成sparklyr,必须用sparkR完成
【问题讨论】:
标签: r apache-spark sparkr als