pyspark - 如何确定 Spark 中 ALS.transImplicit 的偏好/置信度?

标签 pyspark apache-spark-mllib

我正在使用 trainsimplicit来自 ALS在 Spark 。
从文档页面:http://spark.apache.org/docs/latest/api/python/pyspark.mllib.html#pyspark.mllib.recommendation.ALS.trainImplicit , 使用 trainImplicit(ratings, rank, iterations=5, lambda_=0.01, blocks=-1, alpha=0.01, nonnegative=False, seed=None)训练模型。

我的问题是我们应该输入 ratings(user, product, view times/watching time >0) ?
(user, product, preference = 0/1) ?

同时,我注意到如果 alpha =0.01更改为其他值,结果会有所不同。我们怎么知道哪个偏好-置信关系,比如c = 1 + alpha * r1+ alpha * log(1+r/e) ( r 可以是持续时间或频率数)在训练期间在 Spark 中使用?

我也注意到,在网上 https://spark.apache.org/docs/1.4.0/api/python/_modules/pyspark/mllib/recommendation.html#ALS.trainImplicit ,还有clstrainsimplicit类方法。这是一种定义偏好-置信关系的方法吗?

非常感谢!

最佳答案

隐含偏好的含义是,每次用户查看/观看产品时,您的信心都会增加。正确的?
因此输入应该是 (user, product, view times/watching time >0)如果您将输入限制为 0/1 偏好,您只会丢失信息。

正如我从 original spark code 看到的

if (implicitPrefs) {
  // Extension to the original paper to handle b < 0. confidence is a function of |b|
  // instead so that it is never negative. c1 is confidence - 1.0.
  val c1 = alpha * math.abs(rating)
  // For rating <= 0, the corresponding preference is 0. So the term below is only added
  // for rating > 0. Because YtY is already added, we need to adjust the scaling here.
  if (rating > 0) {
    numExplicits += 1
    ls.add(srcFactor, (c1 + 1.0) / c1, c1)
  }
} 

ALS 使用线性依赖的修改版本。

我从来没有看到任何关于这方面的文件

关于pyspark - 如何确定 Spark 中 ALS.transImplicit 的偏好/置信度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38752606/

相关文章:

pyspark - 增加 HIVE 中的最大行大小

pyspark - pyspark SVD 特征向量与 PCA 特征向量之间的差异意味着什么?

java - 如何使用 Java 在 Spark 中组合或合并两个稀疏 vector ?

apache-spark - 在spark mllib中,LogisticRegressionWithSGD可以做多个分类任务吗?

java - Scala Spark MLLib NoClassDefFoundError

apache-spark - 保存 ML 模型以供将来使用

python - 根据列获取 pyspark 中的本地时间

python - 每当我开始时,Pyspark都会给这些

apache-spark - Spark : Removing rows which occur less than N times

apache-spark - Spark (OneHotEncoder + StringIndexer) = FeatureImportance 如何?