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

    https://github.com/apache/spark/pull/8112#discussion_r40270977
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/util/MLUtils.scala ---
    @@ -267,6 +268,26 @@ object MLUtils {
       }
     
       /**
    +   * :: Experimental ::
    +   * Return a k element array of pairs of RDDs with the first element of 
each pair
    +   * containing the training data, a complement of the validation data and 
the second
    +   * element, the validation data, containing a unique 1/kth of the data. 
Where k=numFolds.
    +   * The training and validation data are stratified by the key of the 
rdd, and the key
    +   * ratios in the original data are maintained in each stratum of the 
train and validation
    +   * data.
    +   */
    +  @Experimental
    +  def kFoldStratified[K: ClassTag, V: ClassTag](rdd: RDD[(K, V)],
    +      numFolds: Int,
    +      seed: Int): Array[(RDD[(K, V)], RDD[(K, V)])] = {
    +    val keys = rdd.keys.collect().distinct
    --- End diff --
    
    Best to swap the `distinct` and `collect` calls to avoid running out of 
memory on the driver.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to