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

    https://github.com/apache/spark/pull/11581#discussion_r56014633
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Impurity.scala ---
    @@ -179,3 +179,21 @@ private[spark] abstract class ImpurityCalculator(val 
stats: Array[Double]) exten
       }
     
     }
    +
    +private[spark] object ImpurityCalculator {
    +
    +  /**
    +   * Create an [[ImpurityCalculator]] instance of the given impurity type 
and with
    +   * the given stats.
    +   */
    +  def getCalculator(impurity: String, stats: Array[Double]): 
ImpurityCalculator = {
    +    impurity match {
    +      case "gini" => new GiniCalculator(stats)
    +      case "entropy" => new EntropyCalculator(stats)
    +      case "variance" => new VarianceCalculator(stats)
    --- End diff --
    
    String references are error-prone. It's better to add a string name for 
each Calculator, then use ```GiniCalculator.name``` rather than directly use 
"gini" here. 


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