[ 
https://issues.apache.org/jira/browse/SPARK-20271?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

yuhao yang updated SPARK-20271:
-------------------------------
    Description: 
Just to share some code I implemented to help easily create a custom 
Transformer in one line of code w.
{code} val labelConverter = new FuncTransformer((i: Double) => if (i >= 1) 1 
else 0) {code}

This was used in many of my projects and is pretty helpful (Maybe I'm lazy..). 
The transformer can be saved/loaded as other transformer and can be integrated 
into a pipeline normally.  It can be used widely in many use cases like 
conditional conversion(if...else...), , type conversion, to/from Array, to/from 
Vector and many string ops..




  was:
Just to share some code I implemented to help easily create a custom 
Transformer in one line of code w.
{code} val labelConverter = new FuncTransformer((i: Double) => if (i >= 1) 1 
else 0) {code}

This was used in many of my projects and is pretty helpful (Maybe I'm lazy..). 
The transformer can be saved/loaded as other transformer and can be integrated 
into a pipeline normally. It can be used widely in many use cases and you can 
find some examples in the PR.





> Add FuncTransformer to simplify custom transformer creation
> -----------------------------------------------------------
>
>                 Key: SPARK-20271
>                 URL: https://issues.apache.org/jira/browse/SPARK-20271
>             Project: Spark
>          Issue Type: New Feature
>          Components: ML
>    Affects Versions: 2.2.0
>            Reporter: yuhao yang
>
> Just to share some code I implemented to help easily create a custom 
> Transformer in one line of code w.
> {code} val labelConverter = new FuncTransformer((i: Double) => if (i >= 1) 1 
> else 0) {code}
> This was used in many of my projects and is pretty helpful (Maybe I'm 
> lazy..). The transformer can be saved/loaded as other transformer and can be 
> integrated into a pipeline normally.  It can be used widely in many use cases 
> like conditional conversion(if...else...), , type conversion, to/from Array, 
> to/from Vector and many string ops..



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

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

Reply via email to