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

    https://github.com/apache/spark/pull/11553#discussion_r57414476
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/feature/QuantileDiscretizer.scala ---
    @@ -89,12 +106,13 @@ final class QuantileDiscretizer(override val uid: 
String)
       }
     
       override def fit(dataset: DataFrame): Bucketizer = {
    -    val samples = QuantileDiscretizer
    -      .getSampledInput(dataset.select($(inputCol)), $(numBuckets), $(seed))
    -      .map { case Row(feature: Double) => feature }
    -    val candidates = QuantileDiscretizer.findSplitCandidates(samples, 
$(numBuckets) - 1)
    -    val splits = QuantileDiscretizer.getSplits(candidates)
    -    val bucketizer = new Bucketizer(uid).setSplits(splits)
    +    val splits = dataset.stat.approxQuantile($(inputCol),
    +      (0.0 to 1.0 by 1.0/$(numBuckets)).toArray, getRelativeError)
    +
    +    // adjust splits to be consistent with class description
    +    val adjustedSplits = Double.NegativeInfinity +:
    +      splits.drop(1).dropRight(1) :+ Double.PositiveInfinity
    --- End diff --
    
    ~~~scala
    splits(0) =  Double.NegativeInfinity
    splits(splits.length - 1) = Double.PositiveInfinity
    ~~~
    
    to avoid creating temp arrays.


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