You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by me...@apache.org on 2015/09/30 08:58:38 UTC
spark git commit: [SPARK-10736] [ML] Use 1 for all ratings if
$(ratingCol) = ""
Repository: spark
Updated Branches:
refs/heads/master 4d5a005b0 -> 2931e89f0
[SPARK-10736] [ML] Use 1 for all ratings if $(ratingCol) = ""
For some implicit dataset, ratings may not exist in the training data. In this case, we can assume all observed pairs to be positive and treat their ratings as 1. This should happen when users set ```ratingCol``` to an empty string.
Author: Yanbo Liang <yb...@gmail.com>
Closes #8937 from yanboliang/spark-10736.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2931e89f
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2931e89f
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2931e89f
Branch: refs/heads/master
Commit: 2931e89f0c54248d87f1f84c81137a5a91e142e9
Parents: 4d5a005
Author: Yanbo Liang <yb...@gmail.com>
Authored: Tue Sep 29 23:58:32 2015 -0700
Committer: Xiangrui Meng <me...@databricks.com>
Committed: Tue Sep 29 23:58:32 2015 -0700
----------------------------------------------------------------------
.../src/main/scala/org/apache/spark/ml/recommendation/ALS.scala | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/2931e89f/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
index 9a56a75..f6f5281 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
@@ -315,9 +315,9 @@ class ALS(override val uid: String) extends Estimator[ALSModel] with ALSParams {
override def fit(dataset: DataFrame): ALSModel = {
import dataset.sqlContext.implicits._
+ val r = if ($(ratingCol) != "") col($(ratingCol)).cast(FloatType) else lit(1.0f)
val ratings = dataset
- .select(col($(userCol)).cast(IntegerType), col($(itemCol)).cast(IntegerType),
- col($(ratingCol)).cast(FloatType))
+ .select(col($(userCol)).cast(IntegerType), col($(itemCol)).cast(IntegerType), r)
.map { row =>
Rating(row.getInt(0), row.getInt(1), row.getFloat(2))
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org