zhengruifeng commented on code in PR #44526:
URL: https://github.com/apache/spark/pull/44526#discussion_r1437621074
##########
mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala:
##########
@@ -324,13 +324,22 @@ class ALSModel private[ml] (
// create a new column named map(predictionCol) by running the predict UDF.
val validatedUsers = checkIntegers(dataset, $(userCol))
val validatedItems = checkIntegers(dataset, $(itemCol))
+
+ val validatedInputAlias = Identifiable.randomUID("__als_validated_input")
+ val itemFactorsAlias = Identifiable.randomUID("__als_item_factors")
+ val userFactorsAlias = Identifiable.randomUID("__als_user_factors")
+
val predictions = dataset
- .join(userFactors,
- validatedUsers === userFactors("id"), "left")
- .join(itemFactors,
- validatedItems === itemFactors("id"), "left")
- .select(dataset("*"),
- predict(userFactors("features"),
itemFactors("features")).as($(predictionCol)))
+ .withColumns(Map($(userCol) -> validatedUsers, $(itemCol) ->
validatedItems))
Review Comment:
It maybe not needed, I want to use `withColumns` to validate the columns
first (while keep the column name) and then reference the validated column by
`s"${validatedInputAlias}.${$(itemCol)}"`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]