Github user sethah commented on a diff in the pull request:
https://github.com/apache/spark/pull/15435#discussion_r94638095
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
---
@@ -149,15 +149,34 @@ class LogisticRegressionSuite
assert(copiedModel.hasSummary)
}
- test("empty probabilityCol") {
- val lr = new LogisticRegression().setProbabilityCol("")
- val model = lr.fit(smallBinaryDataset)
+ test("empty probabilityCol or predictionCol") {
+ var lr = new LogisticRegression().setProbabilityCol("")
--- End diff --
I think we can get rid of the vars and shorten this up. Also, we should
probably test both binary and multiclass. How does this look?:
````scala
val lr = new LogisticRegression().setMaxIter(1)
val datasetFieldNames = smallBinaryDataset.schema.fieldNames.toSet
def checkSummarySchema(model: LogisticRegressionModel, columns:
Seq[String]): Unit = {
val fieldNames = model.summary.predictions.schema.fieldNames
assert(model.hasSummary)
assert(datasetFieldNames.subsetOf(fieldNames.toSet))
columns.foreach { c => assert(fieldNames.exists(_.startsWith(c))) }
}
Seq("binomial", "multinomial").foreach { family =>
lr.setProbabilityCol("")
val modelNoProb = lr.fit(smallBinaryDataset)
checkSummarySchema(modelNoProb, Seq("probability_"))
lr.setProbabilityCol("probability").setPredictionCol("")
val modelNoPred = lr.fit(smallBinaryDataset)
checkSummarySchema(modelNoPred, Seq("prediction_"))
lr.setProbabilityCol("").setPredictionCol("")
val modelNoPredNoProb = lr.fit(smallBinaryDataset)
checkSummarySchema(modelNoPredNoProb, Seq("prediction_",
"probability_"))
}
````
---
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]