viirya 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_r365044682
##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala
##########
@@ -442,11 +488,17 @@ object RFormulaModel extends MLReadable[RFormulaModel] {
val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
val dataPath = new Path(path, "data").toString
- val data = sparkSession.read.parquet(dataPath).select("label", "terms",
"hasIntercept").head()
+ val df = sparkSession.read.parquet(dataPath)
+ val columns = Seq("label", "terms", "hasIntercept", "evalExprs")
+ val data = df.select(columns.intersect(df.columns).map(df(_)): _*)
+ .head()
val label = data.getString(0)
val terms = data.getAs[Seq[Seq[String]]](1)
val hasIntercept = data.getBoolean(2)
- val resolvedRFormula = ResolvedRFormula(label, terms, hasIntercept)
+ // Check for old saved models (spark version < 3), they do not have
evalExprs.
+ val (major, minor) =
VersionUtils.majorMinorVersion(metadata.sparkVersion)
+ val evalExprs = if (major.toInt < 3) Seq[String]() else
data.getAs[Seq[String]](3)
+ val resolvedRFormula = ResolvedRFormula(label, terms, hasIntercept,
evalExprs)
Review comment:
Looks correct. We better have a test for this. We can load a model from 2.4
in a test case. There are few examples in ml.
----------------------------------------------------------------
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]