You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by MLnick <gi...@git.apache.org> on 2017/05/02 09:50:53 UTC

[GitHub] spark pull request #17793: [SPARK-20484][MLLIB] Add documentation to ALS cod...

Github user MLnick commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17793#discussion_r114283898
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala ---
    @@ -791,32 +813,43 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
           checkpointInterval: Int = 10,
           seed: Long = 0L)(
           implicit ord: Ordering[ID]): (RDD[(ID, Array[Float])], RDD[(ID, Array[Float])]) = {
    +
         require(!ratings.isEmpty(), s"No ratings available from $ratings")
         require(intermediateRDDStorageLevel != StorageLevel.NONE,
           "ALS is not designed to run without persisting intermediate RDDs.")
    +
         val sc = ratings.sparkContext
    +
    +    // Precompute the rating dependencies of each partition
         val userPart = new ALSPartitioner(numUserBlocks)
         val itemPart = new ALSPartitioner(numItemBlocks)
    -    val userLocalIndexEncoder = new LocalIndexEncoder(userPart.numPartitions)
    -    val itemLocalIndexEncoder = new LocalIndexEncoder(itemPart.numPartitions)
    -    val solver = if (nonnegative) new NNLSSolver else new CholeskySolver
         val blockRatings = partitionRatings(ratings, userPart, itemPart)
           .persist(intermediateRDDStorageLevel)
         val (userInBlocks, userOutBlocks) =
           makeBlocks("user", blockRatings, userPart, itemPart, intermediateRDDStorageLevel)
    -    // materialize blockRatings and user blocks
    -    userOutBlocks.count()
    +    userOutBlocks.count()    // materialize blockRatings and user blocks
         val swappedBlockRatings = blockRatings.map {
           case ((userBlockId, itemBlockId), RatingBlock(userIds, itemIds, localRatings)) =>
             ((itemBlockId, userBlockId), RatingBlock(itemIds, userIds, localRatings))
         }
         val (itemInBlocks, itemOutBlocks) =
           makeBlocks("item", swappedBlockRatings, itemPart, userPart, intermediateRDDStorageLevel)
    -    // materialize item blocks
    -    itemOutBlocks.count()
    +    itemOutBlocks.count()    // materialize item blocks
    +
    +    // Encoders for storing each user/item's partition ID and index within its partition using a
    --- End diff --
    
    Why not add the comment before the encoder `val`s are defined? You could add a space in between the solver if you want to disambiguate the comment


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org