ozancicek commented on a change in pull request #24939: [SPARK-18569][ML][R] 
Support RFormula arithmetic, I() and spark functions
URL: https://github.com/apache/spark/pull/24939#discussion_r365503203
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala
 ##########
 @@ -344,29 +360,28 @@ class RFormulaModel private[feature](
     private[ml] val pipelineModel: PipelineModel)
   extends Model[RFormulaModel] with RFormulaBase with MLWritable {
 
+  private val foldExprs = (df: DataFrame) => 
resolvedFormula.evalExprs.foldLeft(df) _
+
   @Since("2.0.0")
   override def transform(dataset: Dataset[_]): DataFrame = {
     checkCanTransform(dataset.schema)
-    transformLabel(pipelineModel.transform(dataset))
+    val withExprs = foldExprs(dataset.toDF) {
+      case(df, colname) => df.withColumn(colname, expr(colname))
+    }
 
 Review comment:
   Thanks, I wasn't aware of that function. Switched to withColumns.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to