Github user tomerk commented on the pull request:

    https://github.com/apache/spark/pull/3637#issuecomment-69393149
  
    After taking a look at this pull request I have a few thoughts on what 
could make it simpler for developers to create new Transformers and Estimators: 
    - I can't quite tell from the conversation tab if the Typed vs. Untyped 
interface for Estimators has been resolved yet or not. My vote would be that 
regardless of if a strongly typed interface is exposed to the public, a 
strongly typed interface would be simpler for developers to extend. I 
personally think it would be reasonable to have a strongly typed interface that 
only some Estimators extend from if it's not being exposed to the public.  
    
    - At the start of every transform and fit function developers have to 
remember to call:
    ```sh
    transformSchema(dataset.schema, paramMap, logging = true)
    val map = this.paramMap ++ paramMap
    ```  
    It doesn't seem like it should be that hard to make protected functions 
developers need to extend which don't have to do this, and then have fit and 
transform execute these two lines before entering the appropriate protected 
method.
    
    - If we parameterize all the sharedParams mixins, it may be possible to not 
have to implement setters.
    e.g. if we defined HasRawPredictionCol along the lines of:
    ```
    private[ml] trait HasRawPredictionCol[+T] extends Params {
      /** param for raw prediction column name */
      val rawPredictionCol: Param[String] =
        new Param(this, "rawPredictionCol", "raw prediction (a.k.a. confidence) 
column name",
          Some("rawPrediction"))
      def getRawPredictionCol: String = get(rawPredictionCol)
      def setRawPredictionCol(value: String): T = set(rawPredictionCol, 
value).asInstanceOf[T]
    }
    ```
    and then passed in the f-bounded type (which we're capturing anyway) when 
specifying ```with HasRawPredictionCol[M]```, classes that mix it in don't have 
to specify the setters.
    
    - Would it be reasonable to make it so UnaryTransformers and other strongly 
typed interfaces use TypeTags and ```ScalaReflection.schemaFor[T].dataType``` 
to figure out the appropriate input and output datatypes? Then specifying a new 
UnaryTransformer could be as easy as just implementing a new function, no need 
to figure out how the input and output types exactly translate into catalyst 
datatypes. This may have plenty of issues as I'm not familiar with spark sql, 
but it could allow syntactic sugar such as:
    ``` val tokenizer(sep: String) = Transformer[String, 
Seq[String]](_.split(sep))```


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to