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_r320706146
##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala
##########
@@ -216,9 +226,14 @@ class RFormula @Since("1.5.0") (@Since("1.5.0") override
val uid: String)
col
}
- // First we index each string column referenced by the input terms.
+ // Add evaluated expressions to the dataset
+ val selectedCols = resolvedFormula.evalExprs
+ .map(col => expr(col).alias(col)) ++ dataset.columns.map(col(_))
Review comment:
Most of the time the name stays the same, but there are still some cases
name might change. For example when casting is involved;
```scala
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
val spark = SparkSession.builder()
.master("local")
.getOrCreate()
import spark.implicits._
Seq(1, 2, 3, 4, 5).toDF.select(expr("log(value)")).show()
+-------------------------------+
|LOG(E(), CAST(value AS DOUBLE))|
+-------------------------------+
| 0.0|
| 0.6931471805599453|
| 1.0986122886681098|
| 1.3862943611198906|
| 1.6094379124341003|
+-------------------------------+
```
----------------------------------------------------------------
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]