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

    https://github.com/apache/spark/pull/1713#discussion_r15684527
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/stat/correlation/Correlation.scala 
---
    @@ -49,43 +49,48 @@ private[stat] trait Correlation {
     }
     
     /**
    - * Delegates computation to the specific correlation object based on the 
input method name
    - *
    - * Currently supported correlations: pearson, spearman.
    - * After new correlation algorithms are added, please update the 
documentation here and in
    - * Statistics.scala for the correlation APIs.
    - *
    - * Maintains the default correlation type, pearson
    + * Delegates computation to the specific correlation object based on the 
input method name.
      */
     private[stat] object Correlations {
     
    -  // Note: after new types of correlations are implemented, please update 
this map
    -  val nameToObjectMap = Map(("pearson", PearsonCorrelation), ("spearman", 
SpearmanCorrelation))
    -  val defaultCorrName: String = "pearson"
    -  val defaultCorr: Correlation = nameToObjectMap(defaultCorrName)
    -
    -  def corr(x: RDD[Double], y: RDD[Double], method: String = 
defaultCorrName): Double = {
    +  def corr(x: RDD[Double],
    +       y: RDD[Double],
    +       method: String = CorrelationNames.defaultCorrName): Double = {
         val correlation = getCorrelationFromName(method)
         correlation.computeCorrelation(x, y)
       }
     
    -  def corrMatrix(X: RDD[Vector], method: String = defaultCorrName): Matrix 
= {
    +  def corrMatrix(X: RDD[Vector],
    +      method: String = CorrelationNames.defaultCorrName): Matrix = {
         val correlation = getCorrelationFromName(method)
         correlation.computeCorrelationMatrix(X)
       }
     
    -  /**
    -   * Match input correlation name with a known name via simple string 
matching
    -   *
    -   * private to stat for ease of unit testing
    -   */
    -  private[stat] def getCorrelationFromName(method: String): Correlation = {
    +  // Match input correlation name with a known name via simple string 
matching.
    +  def getCorrelationFromName(method: String): Correlation = {
         try {
    -      nameToObjectMap(method)
    +      CorrelationNames.nameToObjectMap(method)
         } catch {
           case nse: NoSuchElementException =>
             throw new IllegalArgumentException("Unrecognized method name. 
Supported correlations: "
    -          + nameToObjectMap.keys.mkString(", "))
    +          + CorrelationNames.nameToObjectMap.keys.mkString(", "))
         }
       }
     }
    +
    +/**
    + * Maintains supported and default correlation names.
    + *
    + * Currently supported correlations: `pearson`, `spearman`.
    + * Current default correlation: `pearson`.
    + *
    + * After new correlation algorithms are added, please update the 
documentation here and in
    + * Statistics.scala for the correlation APIs.
    + */
    +object CorrelationNames {
    --- End diff --
    
    I originally planned on using it inside of pyspark but `private[mllib]` is 
sufficient scope now.


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

Reply via email to