spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkbradley <...@git.apache.org>
Subject [GitHub] spark pull request #17373: [SPARK-12664][ML] Expose probability in mlp model
Date Mon, 14 Aug 2017 22:58:38 GMT
Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17373#discussion_r133082415
  
    --- Diff: mllib/src/test/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifierSuite.scala
---
    @@ -82,6 +83,49 @@ class MultilayerPerceptronClassifierSuite
         }
       }
     
    +  test("strong dataset test") {
    +    val layers = Array[Int](4, 5, 5, 2)
    +
    +    val strongDataset = Seq(
    +      (Vectors.dense(1, 2, 3, 4), 0d, Vectors.dense(1d, 0d)),
    +      (Vectors.dense(4, 3, 2, 1), 1d, Vectors.dense(0d, 1d)),
    +      (Vectors.dense(1, 1, 1, 1), 0d, Vectors.dense(.5, .5)),
    +      (Vectors.dense(1, 1, 1, 1), 1d, Vectors.dense(.5, .5))
    +    ).toDF("features", "label", "expectedProbability")
    +    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)
    +    result.select("probability", "expectedProbability").collect().foreach {
    +      case Row(p: Vector, e: Vector) =>
    +        assert(p ~== e absTol 1e-3)
    +    }
    +  }
    +
    +  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")
    --- End diff --
    
    That's the default already, right?


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

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


Mime
View raw message