ozancicek commented on a change in pull request #24764: [SPARK-18570][ML][R]
RFormula support * and ^ operators
URL: https://github.com/apache/spark/pull/24764#discussion_r289751642
##########
File path:
mllib/src/test/scala/org/apache/spark/ml/feature/RFormulaParserSuite.scala
##########
@@ -90,12 +90,48 @@ class RFormulaParserSuite extends SparkFunSuite {
test("parse interactions") {
checkParse("y ~ a:b", "y", Seq("a:b"))
+ checkParse("y ~ a:b + b:a", "y", Seq("a:b"))
checkParse("y ~ ._a:._x", "y", Seq("._a:._x"))
checkParse("y ~ foo:bar", "y", Seq("foo:bar"))
checkParse("y ~ a : b : c", "y", Seq("a:b:c"))
checkParse("y ~ q + a:b:c + b:c + c:d + z", "y", Seq("q", "a:b:c", "b:c",
"c:d", "z"))
}
+ test("parse factor cross") {
+ checkParse("y ~ a*b", "y", Seq("a", "b", "a:b"))
+ checkParse("y ~ a*b + b*a", "y", Seq("a", "b", "a:b"))
+ checkParse("y ~ ._a*._x", "y", Seq("._a", "._x", "._a:._x"))
+ checkParse("y ~ foo*bar", "y", Seq("foo", "bar", "foo:bar"))
+ checkParse("y ~ a * b * c", "y", Seq("a", "b", "a:b", "c", "a:c", "b:c",
"a:b:c"))
+ }
+
+ test("interaction distributive") {
+ checkParse("y ~ (a + b):c", "y", Seq("a:c", "b:c"))
+ checkParse("y ~ c:(a + b)", "y", Seq("c:a", "c:b"))
+ }
+
+ test("factor cross distributive") {
+ checkParse("y ~ (a + b)*c", "y", Seq("a", "b", "c", "a:c", "b:c"))
+ checkParse("y ~ c*(a + b)", "y", Seq("c", "a", "b", "c:a", "c:b"))
Review comment:
Yes that's right, if we end up generating `a:c` and `c:a`, only `a:c` should
return. I've added some checks for that on lines 93 and 102 on
RFormulaParserSuite.scala. Do you have additional test cases in mind or are
those good enough?
----------------------------------------------------------------
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]