You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2018/01/20 06:46:42 UTC
spark git commit: [SPARK-23091][ML] Incorrect unit test for
approxQuantile
Repository: spark
Updated Branches:
refs/heads/master 793841c6b -> 396cdfbea
[SPARK-23091][ML] Incorrect unit test for approxQuantile
## What changes were proposed in this pull request?
Narrow bound on approx quantile test to epsilon from 2*epsilon to match paper
## How was this patch tested?
Existing tests.
Author: Sean Owen <so...@cloudera.com>
Closes #20324 from srowen/SPARK-23091.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/396cdfbe
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/396cdfbe
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/396cdfbe
Branch: refs/heads/master
Commit: 396cdfbea45232bacbc03bfaf8be4ea85d47d3fd
Parents: 793841c
Author: Sean Owen <so...@cloudera.com>
Authored: Fri Jan 19 22:46:34 2018 -0800
Committer: gatorsmile <ga...@gmail.com>
Committed: Fri Jan 19 22:46:34 2018 -0800
----------------------------------------------------------------------
.../apache/spark/sql/DataFrameStatSuite.scala | 24 ++++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/396cdfbe/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
index 5169d2b..8eae353 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
@@ -154,24 +154,24 @@ class DataFrameStatSuite extends QueryTest with SharedSQLContext {
val Array(d1, d2) = df.stat.approxQuantile("doubles", Array(q1, q2), epsilon)
val Array(s1, s2) = df.stat.approxQuantile("singles", Array(q1, q2), epsilon)
- val error_single = 2 * 1000 * epsilon
- val error_double = 2 * 2000 * epsilon
+ val errorSingle = 1000 * epsilon
+ val errorDouble = 2.0 * errorSingle
- assert(math.abs(single1 - q1 * n) < error_single)
- assert(math.abs(double2 - 2 * q2 * n) < error_double)
- assert(math.abs(s1 - q1 * n) < error_single)
- assert(math.abs(s2 - q2 * n) < error_single)
- assert(math.abs(d1 - 2 * q1 * n) < error_double)
- assert(math.abs(d2 - 2 * q2 * n) < error_double)
+ assert(math.abs(single1 - q1 * n) <= errorSingle)
+ assert(math.abs(double2 - 2 * q2 * n) <= errorDouble)
+ assert(math.abs(s1 - q1 * n) <= errorSingle)
+ assert(math.abs(s2 - q2 * n) <= errorSingle)
+ assert(math.abs(d1 - 2 * q1 * n) <= errorDouble)
+ assert(math.abs(d2 - 2 * q2 * n) <= errorDouble)
// Multiple columns
val Array(Array(ms1, ms2), Array(md1, md2)) =
df.stat.approxQuantile(Array("singles", "doubles"), Array(q1, q2), epsilon)
- assert(math.abs(ms1 - q1 * n) < error_single)
- assert(math.abs(ms2 - q2 * n) < error_single)
- assert(math.abs(md1 - 2 * q1 * n) < error_double)
- assert(math.abs(md2 - 2 * q2 * n) < error_double)
+ assert(math.abs(ms1 - q1 * n) <= errorSingle)
+ assert(math.abs(ms2 - q2 * n) <= errorSingle)
+ assert(math.abs(md1 - 2 * q1 * n) <= errorDouble)
+ assert(math.abs(md2 - 2 * q2 * n) <= errorDouble)
}
// quantile should be in the range [0.0, 1.0]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org