Github user MLnick commented on a diff in the pull request: https://github.com/apache/spark/pull/11553#discussion_r56956545 --- Diff: mllib/src/test/scala/org/apache/spark/ml/feature/QuantileDiscretizerSuite.scala --- @@ -91,6 +44,46 @@ class QuantileDiscretizerSuite "Observed number of buckets does not equal expected number of buckets.") } + test("Test transform method on unseen data") { + val sqlCtx = SQLContext.getOrCreate(sc) + import sqlCtx.implicits._ + + val trainDF = sc.parallelize(1.0 to 100.0 by 1.0).map(Tuple1.apply).toDF("input") + val testDF = sc.parallelize(-10.0 to 110.0 by 1.0).map(Tuple1.apply).toDF("input") + val discretizer = new QuantileDiscretizer() + .setInputCol("input") + .setOutputCol("result") + .setNumBuckets(5) + + val result = discretizer.fit(trainDF).transform(testDF) + val firstBucketSize = result.filter(result("result") === 0.0).count + val lastBucketSize = result.filter(result("result") === 4.0).count + + assert(firstBucketSize === 30L, + "Size of first bucket did not equal expected value.") + assert(lastBucketSize === 31L, + "Size of last bucket did not equal expected value.") + } + + test("Test default relativeError and setRelativeError") { + val discretizer = new QuantileDiscretizer() + val testValues = Array(0.1, 0.2, 0.3, 0.4) --- End diff -- minor, but having these values is not really testing much. Perhaps `Array(0.0, 0.005, 0.1)` will be better, to test that we can set an explicit value below, between and above the default range.
--- 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