Github user MechCoder commented on a diff in the pull request:
https://github.com/apache/spark/pull/7879#discussion_r36062700
--- 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 --
Not a PySpark comment, but is this expected behavior?
>>> df = sqlContext.createDataFrame([
... (1.0, 1.0, "a"),
... (0.0, 2.0, "b"),
... (0.0, 0.0, "c")
... ], ["y", "x", "s"])
>>> rf.fit(df).transform(df).collect()
[Row(y=1.0, x=1.0, s='a', features=DenseVector([1.0, 1.0, 0.0]),
label=1.0),
Row(y=0.0, x=2.0, s='b', features=DenseVector([2.0, 0.0, 1.0]),
label=0.0),
Row(y=0.0, x=0.0, s='c', features=SparseVector(3, {}), label=0.0)]
---
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]