Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/7879#discussion_r36113315
--- Diff: python/pyspark/ml/feature.py ---
@@ -1110,6 +1110,80 @@ class PCAModel(JavaModel):
"""
+@inherit_doc
+class RFormula(JavaEstimator, HasFeaturesCol, HasLabelCol):
+ """
+ .. note:: Experimental
+
+ Implements the transforms required for fitting a dataset against an
+ R model formula. Currently we support a limited subset of the R
+ operators, including '~', '+', '-', and '.'. Also see the R formula
+ docs:
+ http://stat.ethz.ch/R-manual/R-patched/library/stats/html/formula.html
+
+ >>> df = sqlContext.createDataFrame([
+ ... (1.0, 1.0, "a"),
+ ... (0.0, 2.0, "b"),
+ ... (0.0, 0.0, "a")
+ ... ], ["y", "x", "s"])
+ >>> rf = RFormula(formula="y ~ x + s")
+ >>> rf.fit(df).transform(df).show()
--- End diff --
Yes, but I tried to create a small test case such that the behavior is
well-defined, e.g., the ordering of string values. If we use `a`, `b`, and `c`
with each appearing only once, how we determine the indices are not well
defined. Should be a TODO item, but not part of this PR.
For the test, it is following DataFrames tests. It might be simpler to read
as part of the documentation.
---
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]