Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/493#discussion_r12196832
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala ---
@@ -708,6 +709,113 @@ object ALS {
trainImplicit(ratings, rank, iterations, 0.01, -1, 1.0)
}
+ /**
+ * :: DeveloperApi ::
+ * Represents the cost attributable to a partition of a single ALS
iteration.
+ */
+ @DeveloperApi
+ case class IterationCost(inboundVectors: Double, outerProducts: Double,
choleskies: Double,
+ outboundVectors: Double)
+
+ /**
+ * :: DeveloperApi ::
+ * Given an RDD of ratings, a rank, and two partitioners, compute rough
estimates of the
+ * computation time and communication cost of one iteration of ALS.
Returns a pair of
+ * `Seq[IterationCost]`s. The first `Seq` represents user partitions
and the second `Seq`
+ * represents product partitions. These `Seq`s are indexed by partition
numbers, and the `i`th
+ * member contains details for the `i`th partition.
+ *
+ * @param ratings RDD of Rating objects
+ * @param userPartitioner partitioner for partitioning users
+ * @param productPartitioner partitioner for partitioning products
+ */
+ @DeveloperApi
+ def estimateCost(
+ ratings: RDD[Rating],
+ userPartitioner: Partitioner,
+ productPartitioner: Partitioner
+ ): (Seq[IterationCost], Seq[IterationCost]) = {
+ val numUserPartitions = userPartitioner.numPartitions
+ val numProdPartitions = productPartitioner.numPartitions
+
+ val ratingsByUserBlock = ratings.map{ rating =>
--- End diff --
Put a space before `{`. Sorry if the existing code didn't follow this.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---