Github user actuaryzhang commented on the issue:
https://github.com/apache/spark/pull/16630
The following code illustrates the idea of this PR.
```
val datasetWithWeight = Seq(
(1.0, 1.0, 0.0, 5.0),
(0.5, 2.0, 1.0, 2.0),
(1.0, 3.0, 2.0, 1.0),
(0.0, 4.0, 3.0, 3.0)
).toDF("y", "w", "x1", "x2")
val formula = (new RFormula()
.setFormula("y ~ x1 + x2")
.setFeaturesCol("features")
.setLabelCol("label"))
val output = formula.fit(datasetWithWeight).transform(datasetWithWeight)
val glr = new GeneralizedLinearRegression()
val model = glr.fit(output)
model.summary.summaryTable.show
```
This prints out:
```
+---------+--------------------+-------------------+-------------------+-------------------+
| Feature| Estimate| StdError| TValue|
PValue|
+---------+--------------------+-------------------+-------------------+-------------------+
|Intercept| 1.4523809523809539| 0.9245946589975053| 1.5708299180050451|
0.3609009059280113|
|
x1|-0.33333333333333387|0.28171808490950573|-1.1832159566199243|0.44669962096188565|
| x2|-0.11904761904761924| 0.21295885499998|-0.5590169943749482|
0.6754896416955616|
+---------+--------------------+-------------------+-------------------+-------------------+
```
---
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]