spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From imatiach-msft <...@git.apache.org>
Subject [GitHub] spark pull request #16571: [SPARK-19208][ML] MaxAbsScaler and MinMaxScaler a...
Date Fri, 13 Jan 2017 23:43:27 GMT
Github user imatiach-msft commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16571#discussion_r96095807
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/MaxAbsScaler.scala ---
    @@ -70,14 +67,40 @@ class MaxAbsScaler @Since("2.0.0") (@Since("2.0.0") override val uid:
String)
       @Since("2.0.0")
       override def fit(dataset: Dataset[_]): MaxAbsScalerModel = {
         transformSchema(dataset.schema, logging = true)
    -    val input: RDD[OldVector] = dataset.select($(inputCol)).rdd.map {
    -      case Row(v: Vector) => OldVectors.fromML(v)
    -    }
    -    val summary = Statistics.colStats(input)
    -    val minVals = summary.min.toArray
    -    val maxVals = summary.max.toArray
    -    val n = minVals.length
    -    val maxAbs = Array.tabulate(n) { i => math.max(math.abs(minVals(i)), math.abs(maxVals(i)))
}
    +
    +    val maxAbs = dataset.select($(inputCol)).rdd.map {
    +      row => row.getAs[Vector](0)
    --- End diff --
    
    actually, I think it might make the code clearer to:
    1.) map to Array[Double] similar to what you did with vector but take the abs
    2.) instead of using treeAggregate just do a simple reduce on the arrays by getting the
max for each slot
    that would simplify the code more.  Would that be worse performance-wise?


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

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


Mime
View raw message