Github user WeichenXu123 commented on a diff in the pull request:
https://github.com/apache/spark/pull/17373#discussion_r131992917
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifierSuite.scala
---
@@ -83,6 +83,36 @@ class MultilayerPerceptronClassifierSuite
}
}
+ test("strong dataset test") {
+ val layers = Array[Int](4, 5, 5, 4)
+
+ val rnd = new scala.util.Random(1234L)
+
+ val strongDataset = Seq.tabulate(4) { index =>
+ (Vectors.dense(
+ rnd.nextGaussian(),
+ rnd.nextGaussian() * 2.0,
+ rnd.nextGaussian() * 3.0,
+ rnd.nextGaussian() * 2.0
+ ), (index % 4).toDouble)
+ }.toDF("features", "label")
+ val trainer = new MultilayerPerceptronClassifier()
+ .setLayers(layers)
+ .setBlockSize(1)
+ .setSeed(123L)
+ .setMaxIter(100)
+ .setSolver("l-bfgs")
+ val model = trainer.fit(strongDataset)
+ val result = model.transform(strongDataset)
+ model.setProbabilityCol("probability")
+ MLTestingUtils.checkCopyAndUids(trainer, model)
+ // result.select("probability").show(false)
+ val predictionAndLabels = result.select("prediction",
"label").collect()
+ predictionAndLabels.foreach { case Row(p: Double, l: Double) =>
+ assert(p == l)
+ }
+ }
--- End diff --
@MrBago
How do you like this test ?
The probability it generate is
+--------------------------------------------------------------------------------------+
|probability
|
+--------------------------------------------------------------------------------------+
|[0.9917274999513315,0.001511626318489583,0.004831796668307991,0.0019290770618710876]
|
|[4.2392735713619E-12,0.9999999999955336,1.8369996605279208E-14,2.0871629225077174E-13]|
|[1.8975708749716946E-4,5.191732707447977E-22,0.5010860788259045,0.49872416408659836]
|
|[1.6776134471360903E-4,3.9309610969078615E-22,0.49629577580941386,0.5035364628458726]
|
+--------------------------------------------------------------------------------------+
it contains some values near 0.5
---
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]