Github user feynmanliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/7538#discussion_r35675531
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala
---
@@ -699,6 +699,40 @@ class LogisticRegressionSuite extends SparkFunSuite
with MLlibTestSparkContext {
val weightsR = Vectors.dense(0.0, 0.0, 0.0, 0.0)
assert(model1.intercept ~== interceptR relTol 1E-5)
- assert(model1.weights ~= weightsR absTol 1E-6)
+ assert(model1.weights ~== weightsR absTol 1E-6)
+ }
+
+ test("evaluate on test set") {
+ // Evaluate on test set should be same as that of the transformed
training data.
+ val lr = new LogisticRegression()
+ .setMaxIter(10)
+ .setRegParam(1.0)
+ .setThreshold(0.6)
+ val model = lr.fit(dataset)
+ val summary = model.summary
+
+ val sameSummary = model.evaluate(dataset)
+ assert(summary.areaUnderROC() === sameSummary.areaUnderROC())
+ assert(summary.roc().collect() === sameSummary.roc.collect())
+ assert(summary.pr().collect() === sameSummary.pr.collect())
+ assert(
+ summary.fMeasureByThreshold().collect() ===
sameSummary.fMeasureByThreshold().collect())
+ assert(summary.recallByThreshold().collect() ===
sameSummary.recallByThreshold().collect())
+ assert(
+ summary.precisionByThreshold().collect() ===
sameSummary.precisionByThreshold().collect())
+ }
+
+ test("statistics on training data") {
+ val lr = new LogisticRegression()
+ .setMaxIter(10)
+ .setRegParam(1.0)
+ .setThreshold(0.6)
+ val model = lr.fit(dataset)
+ assert(
+ model.summary
+ .objectiveHistory
+ .sliding(2)
+ .forall(x => x(0) >= x(1)))
--- End diff --
nit: state what is being tested ("lossHistory is monotonically decreasing")
in comment
---
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]