Github user WeichenXu123 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17373#discussion_r131824713
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifierSuite.scala
 ---
    @@ -82,6 +83,23 @@ class MultilayerPerceptronClassifierSuite
         }
       }
     
    +  test("test model probability") {
    +    val layers = Array[Int](2, 5, 2)
    +    val trainer = new MultilayerPerceptronClassifier()
    +      .setLayers(layers)
    +      .setBlockSize(1)
    +      .setSeed(123L)
    +      .setMaxIter(100)
    +      .setSolver("l-bfgs")
    +    val model = trainer.fit(dataset)
    +    model.setProbabilityCol("probability")
    +    val result = model.transform(dataset)
    +    val features2prob = udf { features: Vector => 
model.mlpModel.predict(features) }
    +    val cmpVec = udf { (v1: Vector, v2: Vector) => v1 ~== v2 relTol 1e-3 }
    +    assert(result.select(cmpVec(features2prob(col("features")), 
col("probability")))
    +      .rdd.map(_.getBoolean(0)).reduce(_ && _))
    +  }
    +
    --- End diff --
    
    @MrBago 
    Which way of the strong test should be done ? Add a test to check the 
probability vector equals given vectors ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to