You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yan Facai (颜发才 JIRA)" <ji...@apache.org> on 2017/08/11 06:03:00 UTC

[jira] [Comment Edited] (SPARK-21690) one-pass imputer

    [ https://issues.apache.org/jira/browse/SPARK-21690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16122904#comment-16122904 ] 

Yan Facai (颜发才) edited comment on SPARK-21690 at 8/11/17 6:02 AM:
------------------------------------------------------------------

We can use `df.summary("mean")` and `df.stat.approxQuantile(df.columns, Array(0.5), 0.001)`, however, two passes are needed.

How about the solution?

If it's OK, I can work on it.


was (Author: facai):
We can use `df.summary("mean")` and `df.stat.approxQuantile(df.columns, Array(0.5), 0.001), however, two passes are needed.

How about the solution?

If it's OK, I can work on it.

> one-pass imputer
> ----------------
>
>                 Key: SPARK-21690
>                 URL: https://issues.apache.org/jira/browse/SPARK-21690
>             Project: Spark
>          Issue Type: Improvement
>          Components: ML
>    Affects Versions: 2.2.1
>            Reporter: zhengruifeng
>
> {code}
>     val surrogates = $(inputCols).map { inputCol =>
>       val ic = col(inputCol)
>       val filtered = dataset.select(ic.cast(DoubleType))
>         .filter(ic.isNotNull && ic =!= $(missingValue) && !ic.isNaN)
>       if(filtered.take(1).length == 0) {
>         throw new SparkException(s"surrogate cannot be computed. " +
>           s"All the values in $inputCol are Null, Nan or missingValue(${$(missingValue)})")
>       }
>       val surrogate = $(strategy) match {
>         case Imputer.mean => filtered.select(avg(inputCol)).as[Double].first()
>         case Imputer.median => filtered.stat.approxQuantile(inputCol, Array(0.5), 0.001).head
>       }
>       surrogate
>     }
> {code}
> Current impl of {{Imputer}} process one column after after another. In this place, we should parallelize the processing in a more efficient way.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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