Github user imatiach-msft commented on a diff in the pull request:
https://github.com/apache/spark/pull/16441#discussion_r96721137
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/GBTClassifierSuite.scala
---
@@ -66,10 +72,156 @@ class GBTClassifierSuite extends SparkFunSuite with
MLlibTestSparkContext
ParamsSuite.checkParams(new GBTClassifier)
val model = new GBTClassificationModel("gbtc",
Array(new DecisionTreeRegressionModel("dtr", new LeafNode(0.0, 0.0,
null), 1)),
- Array(1.0), 1)
+ Array(1.0), 1, 2)
ParamsSuite.checkParams(model)
}
+ test("GBTClassifier: default params") {
+ val gbt = new GBTClassifier
+ assert(gbt.getLabelCol === "label")
+ assert(gbt.getFeaturesCol === "features")
+ assert(gbt.getPredictionCol === "prediction")
+ assert(gbt.getRawPredictionCol === "rawPrediction")
+ assert(gbt.getProbabilityCol === "probability")
+ val df = trainData.toDF()
+ val model = gbt.fit(df)
+ model.transform(df)
+ .select("label", "probability", "prediction", "rawPrediction")
+ .collect()
+ intercept[NoSuchElementException] {
+ model.getThresholds
+ }
+ assert(model.getFeaturesCol === "features")
+ assert(model.getPredictionCol === "prediction")
+ assert(model.getRawPredictionCol === "rawPrediction")
+ assert(model.getProbabilityCol === "probability")
+ assert(model.hasParent)
+
+ // copied model must have the same parent.
+ MLTestingUtils.checkCopy(model)
+ }
+
+ test("setThreshold, getThreshold") {
+ val gbt = new GBTClassifier
+
+ // default
+ withClue("GBTClassifier should not have thresholds set by default.") {
+ intercept[NoSuchElementException] {
+ gbt.getThresholds
+ }
+ }
+
+ // Set via thresholds
+ val gbt2 = new GBTClassifier
+ val threshold = Array(0.3, 0.7)
+ gbt2.setThresholds(threshold)
+ assert(gbt2.getThresholds.zip(threshold).forall { case(t1, t2) => t1
=== t2 })
--- End diff --
done
---
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]