Github user sethah commented on a diff in the pull request:
https://github.com/apache/spark/pull/15435#discussion_r94638575
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
---
@@ -1762,51 +1781,101 @@ class LogisticRegressionSuite
}
test("evaluate on test set") {
- // TODO: add for multiclass when model summary becomes available
// Evaluate on test set should be same as that of the transformed
training data.
- val lr = new LogisticRegression()
+ val blor = new LogisticRegression()
.setMaxIter(10)
.setRegParam(1.0)
.setThreshold(0.6)
- val model = lr.fit(smallBinaryDataset)
- val summary =
model.summary.asInstanceOf[BinaryLogisticRegressionSummary]
-
- val sameSummary =
-
model.evaluate(smallBinaryDataset).asInstanceOf[BinaryLogisticRegressionSummary]
- assert(summary.areaUnderROC === sameSummary.areaUnderROC)
- assert(summary.roc.collect() === sameSummary.roc.collect())
- assert(summary.pr.collect === sameSummary.pr.collect())
+ val blorModel = blor.fit(smallBinaryDataset)
+ val blorSummary = blorModel.binarySummary
+
+ val sameBlorSummary =
+
blorModel.evaluate(smallBinaryDataset).asInstanceOf[BinaryLogisticRegressionSummary]
+ assert(blorSummary.areaUnderROC === sameBlorSummary.areaUnderROC)
+ assert(blorSummary.roc.collect() === sameBlorSummary.roc.collect())
+ assert(blorSummary.pr.collect === sameBlorSummary.pr.collect())
assert(
- summary.fMeasureByThreshold.collect() ===
sameSummary.fMeasureByThreshold.collect())
- assert(summary.recallByThreshold.collect() ===
sameSummary.recallByThreshold.collect())
+ blorSummary.fMeasureByThreshold.collect() ===
sameBlorSummary.fMeasureByThreshold.collect())
assert(
- summary.precisionByThreshold.collect() ===
sameSummary.precisionByThreshold.collect())
+ blorSummary.recallByThreshold.collect() ===
sameBlorSummary.recallByThreshold.collect())
+ assert(
+ blorSummary.precisionByThreshold.collect()
+ === sameBlorSummary.precisionByThreshold.collect())
+
+ val mlor = new LogisticRegression()
--- End diff --
This is never used since you fit with `blor` below. We can probably make a
single estimator called `lr` and then just reuse it for both tests.
---
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]