Github user imatiach-msft commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16722#discussion_r99277799
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Gini.scala ---
    @@ -80,23 +80,29 @@ object Gini extends Impurity {
      * @param numClasses  Number of classes for label.
      */
     private[spark] class GiniAggregator(numClasses: Int)
    -  extends ImpurityAggregator(numClasses) with Serializable {
    +  extends ImpurityAggregator(numClasses + 1) with Serializable {
     
       /**
        * Update stats for one (node, feature, bin) with the given label.
        * @param allStats  Flat stats array, with stats for this (node, 
feature, bin) contiguous.
        * @param offset    Start index of stats for this (node, feature, bin).
        */
    -  def update(allStats: Array[Double], offset: Int, label: Double, 
instanceWeight: Double): Unit = {
    -    if (label >= statsSize) {
    +  def update(
    +      allStats: Array[Double],
    +      offset: Int,
    +      label: Double,
    +      numSamples: Int,
    +      sampleWeight: Double): Unit = {
    +    if (label >= numClasses) {
           throw new IllegalArgumentException(s"GiniAggregator given label 
$label" +
    --- End diff --
    
    not related to this code review, but it seems a bit strange that each of 
these ImpurityAggregators have the same checks/bounds for label, I would have 
preferred the abstract base class to implement these instead, although it is 
nice to have a more specific error message


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to