Github user zhengruifeng commented on the issue:

    https://github.com/apache/spark/pull/18902
  
    I test the performance on a small data, the value in the following table is 
the average duration in seconds:
    
    |numColums| Old Mean | Old Median | New Mean | New Median |
    |------|----------|------------|----------|------------|
    |1|0.0771394713|0.0658712813|0.080779802|0.048165981499999996|
    |10|0.7234340630999999|0.5954440414|0.0867935197|0.13263428659999998|
    |100|7.3756451568|6.2196631259|0.1911931552|0.8625376817000001|
    
    We can see that, even on a small data, the speedup is significant.
    On big dataset that do not fit in memory, we should obtain better speedup.
    
    and the test code is here:
    
    ```
    import org.apache.spark.ml.feature._
    import org.apache.spark.sql.Row
    import org.apache.spark.sql.types._
    import spark.implicits._
    import scala.util.Random
    
    val seed = 123l
    val random = new Random(seed)
    val n = 10000
    val m = 100
    val rows = sc.parallelize(1 to n).map(i=> 
Row(Array.fill(m)(random.nextDouble): _*))
    val struct = new StructType(Array.range(0,m,1).map(i => 
StructField(s"c$i",DoubleType,true)))
    val df = spark.createDataFrame(rows, struct)
    df.persist()
    df.count()
    
    for (strategy <- Seq("mean", "median"); k <- Seq(1,10,100)) {
    val imputer = new 
Imputer().setStrategy(strategy).setInputCols(Array.range(0,k,1).map(i=>s"c$i")).setOutputCols(Array.range(0,k,1).map(i=>s"o$i"))
    var duration = 0.0
    for (i<- 0 until 10) {
    val start = System.nanoTime()
    imputer.fit(df)
    val end = System.nanoTime()
    duration += (end - start) / 1e9
    }
    println((strategy, k, duration/10))
    }
    ```


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